I am planning on developing a feature for my app leveraging the exposed Asana webhooks around the Attachment entity. According to the supported Resources and Actions document, there only exists webhook support when an Attachment is deleted and undeleted.
My intended use case is to take some action when an Attachment is initially attached/created/added to a Task.
Is this possible?
CC’ing the Webhooks wizard @Phil_Seeman! Thank you!
Please read this before posting
- If you received an error from the API that you’re looking for help with, please include the error in your post and be descriptive of the requests you made that received the errors. To be clear, we need the error in the JSON response from the API, not the error your code raised.
Do not share any API credentials. Please check that the code you’re pasting into the post does not contain any real OAuth tokens or personal access tokens. If you have exposed credentials, you should revoke them immediately.
You CCed the master, can’t do much more than wait for his wisdom
I did not use webhook, but I read a lot about it…
I think that you should do is subscribe to webhook on tasks, not attachments. Then you can subscribe to “change”, on tasks, with filter on fields attachments. You can also subscribe at high level, exemple for every project you have. When a task is created, and an attachment is added, you will be notified about it on your project webhook.
But, that’s only how I “think” it works, as I never really used them in a real life scenario, but, we plan to use them soon in our app.
Depending on how you use the app, I am not sure you must subscribe on task creation, because I think that attachments are always added after, and generates a change. But you should test it to be sure.
I think @Frederic_Malenfant was on the right path in his response. I would set a project-level webhook for each project you want to monitor attachments in; this will send you an event when a task in the monitored project(s) are added or changed. When you get an event, call the API to see if the task has any attachments on it.
If it does, the question then is, is that a newly added attachment or not? I think the only way you’ll know is to maintain your own data store where you keep track of tasks and their known attachments; that way, you’ll be able to tell if an attachment is new - i.e. not already in your list.
I know the above is not a very streamlined solution but I’m not seeing any other ways to accomplish it.