Webhooks for comments only

Hi everyone, :slight_smile:

I tried to do the request below, but I’m not only receiving comment_added but also all other story hooks like “added_to_task” / “liked” / “resource_subtype_changed”

  1. resource = project
  2. filters
    • resourceType: “story”
    • action: “added”
    • resourceSubType: “comment_added”

Is there anyone who can tell me how I can make a request to only receive comment_added hooks?

Secondly, when I tried to create the same webhook with action: “changed” and resourceSubType empty, I never received a webhook. Is this because that this kind of story webhooks are not propagated to the task level?

Any help is much appreciated! :pray:

I don’t think story objects are ever changed, so that functionality makes sense.

You could always filter client side and ignore other subtypes. That being said, I would expect that filter to work. I asked an API team member and they believe it should work as well. Are you able to filter stories by other types of subtype? Like:

  • resourceType: “story”
  • action: “added”
  • resourceSubType: “liked”
1 Like

One can edit a comment which I assume would generate a story changed event, right? - so I think it is possible to get those - but it also makes sense that you wouldn’t see too many of those.

2 Likes

Hi @Ross_Grambo,

I checked with story / added / liked and I can confirm that for this webhook I am also receiving the other resourceSubType “added_to_task” / “resource_subtype_changed” / “comment_added” / …

I did a [GET] webhooks/{{webhook_id}} to double check on the webhook I created and this is the response

{
            "gid": "1192284685922807",
            "resource": {
                "gid": "1184265817685157",
                "resource_type": "project"
            },
            "filters": [
                {
                    "resource_type": "story",
                    "resource_subtype": "liked",
                    "action": "added",
                    "fields": null
                }
            ]
        }

so the error should not be in the creation process but rather in the filtering on the Asana side. Could you let the API team double check if filters work properly, else I’ll be bombarded with irrelevant webhooks.

Thanks!

I’ll let them know!

Hi! Im having trouble to get the comments from a paticular task, i think that this its what you already achieve. Can you help me?

Thanks.

1 Like

Hi @Alejandro_Gonzalez_T ,

yes we already achieved getting comments on a single / particular task. We were having issues with getting them for many tasks at once, but we do this via the events API.

For your usecase you need to use https://developers.asana.com/docs/get-stories-from-a-task and filter on resource_subtype == comment_added. In the opt_fields parameter you can pass fields like html_text, created_by.name, created_at, … so that you don’t need an extra API call to get the text / creator per comment.

Greetings,
Willem

PS: if my answer doesn’t help you, you probably should create a new forum thread (or search if one exists for the “get-stories-from-a-task” API, as this webhooks thread is not really related to your question :slight_smile:

1 Like

Thanks a lot for your time Willem, that very useful. I gonna check it.

Regards.

1 Like

I’m having the same issue here, i set up a webhook for only the commeny_added (as Willem express in the first comment) and im receiving anything that changes in the task. There is a solution to this?

Thanks!

Looks like the eng I talked to was incorrect, we don’t currently allow filtering on subtypes. I put in a request for that functionality to be added.

For now, I’d say the solution is to filter your stories client side. I’ll post back here when subtype filtering functionality is added.