How to configure create task Webhook

Hi Asana,
I created a Webhook to be notified whenever I create a task in a particular project. However, I receive four events after creating a task, please see the events:

[
  {
    user: { gid: '...', resource_type: 'user' },
    created_at: '2023-04-08T18:41:52.410Z',
    action: 'added',
    resource: {
      gid: '...',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    parent: { gid: '...', resource_type: 'project' }
  },
  {
    user: { gid: '...', resource_type: 'user' },
    created_at: '2023-04-08T18:41:52.596Z',
    action: 'added',
    resource: {
      gid: '...',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    parent: { gid: '...', resource_type: 'project' }
  },
  {
    user: { gid: '...', resource_type: 'user' },
    created_at: '2023-04-08T18:41:52.696Z',
    action: 'added',
    resource: {
      gid: '...',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    parent: { gid: '...', resource_type: 'section' }
  },
  {
    user: { gid: '...', resource_type: 'user' },
    created_at: '2023-04-08T18:41:52.704Z',
    action: 'added',
    resource: {
      gid: '...',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    parent: { gid: '...', resource_type: 'section' }
  }
]

Also, modifying the name of an existing task sends two events to the Webhook server. And finally, clicking add task on my Asana account sends two events to the Webhook server. See the snippet for creating the Webhook:

{
  "data": {
    "resource": "<project-gid>",
    "target": "https://.../receiveWebhook",
    "filters": [
        {
            "action": "added",
            "resource_type": "task"
        }
    ]
  }
}

I would want to know how to configure the Webhook so that I receive exactly one event after creating a task in the project. Also, I do not want to receive any event after modifying or clicking the add task button.

Hi @Hyacinth_Ali and welcome to the forum,

I’m afraid that’s just the behavior of Asana webhooks; they are known to be noisy. As a webhook consumer, you’ll have to write your code to account for this behavior.

You are setting a filter which should prevent change events but it seems there’s something about it that’s not being properly registered. The only thing I can see is you’re missing a resource_subtype parameter; try adding

"resource_subtype": "default_task",

to your filter and see if that helps.

That action generates a new task so since you’re asking for webhook events on new tasks, you’re going to receive webhooks in this case, right?