REST API Webhooks - How to subscribe for ticket events.

I created an integration for Asana and would like to get status updates for the tickets sent to asana. I already archived to create a webhook and get events through the webhook but it’s really confusing to find out what changed.

This is the response I get when creating a new task:

[
  {
    user: { gid: '1198854124070575', resource_type: 'user' },
    created_at: '2022-07-05T15:38:56.766Z',
    action: 'added',
    parent: { gid: '1199596827596541', resource_type: 'project' },
    resource: {
      gid: '1202555016845892',
      resource_type: 'task',
      resource_subtype: 'default_task'
    }
  },
  {
    user: { gid: '1198854124070575', resource_type: 'user' },
    created_at: '2022-07-05T15:38:57.173Z',
    action: 'added',
    resource: {
      gid: '1202555016845892',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    parent: { gid: '1199596827596547', resource_type: 'section' }
  }
]

And this is the response when updating the status of a task:

[
  {
    user: { gid: '1198854124070575', resource_type: 'user' },
    created_at: '2022-07-05T15:41:19.347Z',
    action: 'added',
    parent: { gid: '1199596827596546', resource_type: 'section' },
    resource: {
      gid: '1202555016845892',
      resource_type: 'task',
      resource_subtype: 'default_task'
    }
  },
  {
    user: { gid: '1198854124070575', resource_type: 'user' },
    created_at: '2022-07-05T15:41:19.354Z',
    action: 'removed',
    resource: {
      gid: '1202555016845892',
      resource_type: 'task',
      resource_subtype: 'default_task'
    },
    parent: { gid: '1199596827596547', resource_type: 'section' }
  }
]

Seems really confusing to me because the action always is ‘added’ but I only want to notify the user once when the ticket is created in Asana and once when the status is changed.
Does someone have an idea how to archive that?

I also attached the filters I subscribed to when creating the webhook.

              filters: [
                {
                  action: 'added',
                  resource_type: 'task',
                },
                {
                  action: 'changed',
                  resource_type: 'task',
                },
                {
                  action: 'removed',
                  resource_type: 'task',
                },
                {
                  action: 'deleted',
                  resource_type: 'task',
                },
              ],

Thanks for your help!

Summoning @Phil_Seeman the webhook maser :elf:

1 Like

Hi @Tobias9,

Can you say more about what you mean when you say “status”? Is that a custom field you have created in your Asana implementation, or ??

With the “status” I mean the section of a ticket. I want to get updates once the section of a ticket got changed.

I know what you mean, it’s not too intuitive at first glance!

The key is to take the action and the parent as a unit. Together they tell you what happened.

In your first example of the added task, there are two events. In the first one:

    action: 'added',
    parent: { gid: '1199596827596541', resource_type: 'project' },

this tells you that the resource - that is, the task 1202555016845892 - was added to project 1199596827596541.

Here’s the second one:

  action: 'added',
  parent: { gid: '1199596827596547', resource_type: 'section' }

This tells you that the task was added to section 1199596827596547.

That makes sense, right? When you add a new task, it gets added to a project and to a section within that project.

Now look at the case where you moved the task from one section to another. Again there are two events. Here’s the first one:

    action: 'added',
    parent: { gid: '1199596827596546', resource_type: 'section' },

This tells you that the task was added to section 1199596827596546 - I’m sure you’ll find that’s the gid of the section that you moved the task into - so it got added to that section.

And the second event:

    action: 'removed',
    parent: { gid: '1199596827596547', resource_type: 'section' }

tells you that the task got removed from section 1199596827596547 - I’m sure that’s the gid of the section you moved the task out of - so it got removed from that section.