jfk
jfk

Reputation: 36

Using Asana events API for task monitoring

I'm trying to use Asana events API to track changes in one of our projects, more specific task movement between sections. Our workflow is as follows:

  1. We have a project divided into sections.
  2. Each section represents a step in the process. When one step is done, the task is moved to section below.
  3. When a given task reaches a specific step we want to pass it to an external system. It doesn't have to be the full info - basic things + url would be enough.

My idea was to use https://asana.com/developers/api-reference/events to implement a pull-based mechanism to obtain recent changes in tasks.

My problems are:

  1. Events API seem to generate a lot of information, but not the useful ones. Moving one single task between sections generates 3 events (2 "changed" actions, one "added" action marked as "system"). During work many tasks will be moved between many sections, but I'm interested one in one specific sections. How can I finds items moved into that section? I know that there's a resource->text field, but it gives me something like moved from X to Y (ProjectName) which probably is a human readable message that might change in the future
  2. According to documentation the resource key should contain task data, but the only info I see is id and name which is not enough for my case. Is it possible to get hold on tags using events API? Or any other data that would allow us to classify tasks in our system?
  3. Can I listen for events for a specific section instead of tracking the whole project?

Ideas or suggestions are welcome. Thanks

Upvotes: 0

Views: 587

Answers (1)

Andrew Noonan
Andrew Noonan

Reputation: 848

In short:

  1. Yes, answer below.
  2. Yes, answer below.
  3. Unfortunately not, sections are really tasks with a bit of extra functionality. Currently the API represents the relationship between sections and the tasks in them via the memberships field on a task and not the other way.

This should help you achieve what you are looking for, I think.

Let's say you have a project Ninja Pipeline with 2 sections Novice & Expert. Keep in mind, sections are really just tasks whose name ends with a : character with a few extra features in that tasks can belong to them.

Events "bubble up" from children to their parents; therefore, when you the Wombat task in this project form the Novice section to Expert you get 3 events. Starting from the top level going down, they are:

  • The Ninja Pipeline project changed.
  • The Wombat task changed.
  • A story was added to the Wombat task.

For your use case, the most interesting event is the second one about the task changing. The data you really want to know is now that the task changed what is the value of the memberships field on the task. If it is now a member of the section you are interested in, take action, otherwise ignore.

By default, many resources in the API are represented in compact form which usually only includes the id & name. Use the input/output options in order to expand objects or select specific fields you need.

In this case your best bet is to include the query parameter opt_expand=resource when polling events on the project. This should expand all of the resource objects in the payload. For events of type: "task" then if resource.memberships[0].section.id=<id_of_the_section> is true, take action, otherwise ignore.

Upvotes: 0

Related Questions