Reacting to changes

Polling vs. webhooks

It is common for apps to need to determine what has changed in Asana. Knowing this enables many different features and types of apps, such as: reporting, data-backup, keeping two data sets in harmony, triggering automations, and syncing apps, to name a few.

Events are a special type of object that indicate something changed on a specific resource object in Asana. There are two primary mechanisms to programmatically determine what’s changed:

  1. Poll for events, or
  2. Receive events via webhooks

There are pros and cons to each approach. Generally, it is advisable to use polling unless your app’s features require reacting in real time to events Here is an overview of each option:

When to use polling

  • When you don’t need real-time updates. Common examples:
    • Reporting apps
    • Data backup
    • Syncing integrations or automations that don’t need to react in real time

When to use webhooks

  • You need real-time communication
  • You want to respond immediately to an event
  • You want to push data immediately based on changes

🚧

Use polling instead of webhooks if possible

Avoid using webhooks unless reacting to events in real time is a hard requirement for your app

Why webhooks are challenging

Webhooks based solutions are more technically challenging to implement than polling. Here are some of the common challenges and considerations when working with webhooks:

  • Webhooks require creating and maintaining a server to receive events
  • Webhooks require complex and thoughtful architecture e.g. to avoid infinite loops when implementing 2-way syncs, mitigating the fallout from bugs, etc.
  • Webhooks are unreliable and will need a backup solution. Eventually, both your server receiving webhooks and Asana’s service sending them will experience some downtime. This will likely require a back-up polling solution to get systems back in sync.
  • Webhooks are ephemeral and easy to mishandle or lose
  • Asana webhooks are noisy and can be challenging to reason about – a single user action in Asana can result in many events being sent to your server

Resources for implementing Asana webhooks: