We in Developer Relations at Asana are working on creating some example scripts over the next few months to help flesh out how some of these sorts of workflows could be made. One or more with webhooks is definitely on the radar. This script isn’t perfect (there’s some multiple-signal-asynchronous-shutdown stuff that could be better) but it’s a neatened-up iteration of a script I’ve been using for a while when people ask “What do the events for XYZ” look like.
It creates a Flask app that listens for the webhook handshake and answers it; then any incoming webhook events are logged to the command line, pretty much the minimum app that does something with webhooks The basics of this are in the
receive_webhook function towards the bottom of the file.
It also has some convenience around listing, creating, and deleting the webhook just to make all the params clear - most of the rest of the file. I tried to make the code somewhat readable, so I hope it’s pretty easy to follow.
It uses ngrok to avoid the “I have to have a server that is resolvable via DNS on the Internet” issue, which is fine for experimentation, but we recommend doing it “right” with your own DNS-findable server for production use, since ngrok is a “man in the middle” in this setup. This is also why it recommends using a temporary PAT which you can revoke when you’re done. I suspect ngrok will take down old connections from time to time as well, causing this to break if it’s long-running.
Cheers, and if you have any questions or suggestions for changes before we publish these generally I’d love the feedback!
Check it out on Github