Information on new task created in Asana - asana

I am working on an application that needs to take some actions when certain events happen in user's Asana account (such as new task created, new project created and existing task modified). For this I plan to poll the Asana API every 15 mins and check for new activities. At the moment, for new task created event, I am polling the project for all its tasks in one go, but I do not get any time stamp in return. For timestamps I am required to make individual API calls for each task, which will be inefficient and eat into my rate quota.
Could you please let me know what is the best way for me to get information on new task or project created in Asana for a user, without impacting the rate quota a lot?

You can include timestamps and other data using the opt_fields parameter. So for instance, if you just want to know about newly-created tasks, you can use GET .../tasks?opt_fields=created_at,name (assuming you want the name as well).
Hope that helps! (Also, we're working on a subscription system that lets you "listen" to events like task creation, which will be even better - but that's still in the works.)

Related

Zapier: How to make sure that I return items only once for polling trigger

I am implementing a Zapier Integration's polling trigger. I have built a trigger and an API which serves the data correctly. However my concern is about: how to make sure that I provide the new data only, when zapier polls.
I know about the deduplication mechanism. I provide ids in all the items and Zapier makes sure that one item is used only once. However in my application the items can go into hundreds very quickly and in months they will be in thousands and beyond. I want an optimised solution where I serve only the items which will eventually be used by Zapier, thus reducing the memory usage in my application.
Some timestamp can be save for every call, which I can store inside my application but that will not be a foolproof solution. Same API can be used by user in multiple zaps, plus there are sample calls etc.
Great question! The simplest way to do this is to add a date parameter to your API that lets you filter for items created after that date.
Then, in your Zapier code, provide that param for all trigger calls. I'd set the time to 24 hours ago. So, when a trigger fires, it'll only get items created in the last 24 hours. That could be a big list, but items will cycle out after a day.

Find the voice task currently assigned to a specific worker

This sounds pretty straightforward, but I'm not sure it's something I can do. I want to know what voice task a specific worker is currently working on (if any) without having to store this information on my side when the task is assigned to that worker.
The reason why I'm looking for this because I'm using conferences to pick up incoming calls to agents and I want to implement whisper/barge/coach for supervisors.
They'd know which agents are currently on a call (based on the agent's Busy activity) and based on the workerSid of the agent they want to coach, I want to be able to get the voice task they're currently working on and join that conference (since the TaskSid is also the conference friendly name).
I could loop through the current open tasks, trying to find the right one, but there doesn't seem to be anything on a task that is in an assigned status to indicate who it was assigned to.
The only way I can see to do this using only information I can get from Twilio is a bit too messy:
make a REST API call to https://taskrouter.twilio.com/v1/Workspaces/[workspaceSid]/Workers/[workerSid]/Reservations to get all reservations for that worker for all the tasks that currently exist in the workspace.
find all accepted reservations
loop through the tasks the reservations were made for
and find the latest voice task of those to use.
Any other way would seem to involve looping through conferences that are currently in progress, then loop through their participants to find the call leg made to the contact_uri of the agent to coach to identify the right conference to join, which would be even messier in my opinion.
I'm wondering if there's something obvious that I'm missing.
Twilio developer evangelist here.
The way that you've described seems to be the best way I can find to get this information from the API without storing anything yourself.
If you don't want to store the data in your own server, then you could update a worker's attributes with the current voice task SID. You still have to maintain listening for the end of the call and removing the attribute though.

Is there a standard way to add some approval procedure/or at least notification for changes in task groups/builds/etc.?

We had a few cases when:
Someone changes a task group (or build/release/whatever).
Makes some mistake.
Then publishes/saves it.
But doesn't notify anyone that such changes were made.
Some hours later some dependent build breaks because of those changes.
And we have to spend even more time trying to find what and when has changed as it is not often that simple to find out with external task groups.
What we want to have:
Ideally - some approval process for such changes. Kind of like code review, but for task groups/builds.
If not - then at least some way to receive notifications about changes in task groups and etc. we are interested in?
I found neither, and, honestly, doubt that such features are present in the TFS version we use (TFS 2018.2), but perhaps I've missed something.
There isn't any workflow security or approval process for the groups. You could suggest that kind of feature on the developercommunity. Restrict access to edit Task Groups to only those who understand how to bump the Task Group version. That way at least you will keep backward compatibility across your builds unless that explicitly upgrade to that version.
There aren't any built in notifications, but you could create an automated process to send email notifications using PowerShell using the existing API.
Get the Id for the task group using the taskgroups list api
Use the revisions api to get the history _apis/distributedtask/taskgroups/{taskgroupid}/revisions
Send an update for anything that edited today

How to set Asana so emailed-in Tasks are brought to my attention when I log in, without manually searching for them each time?

I just started using Asana to manage bug fixes/feature requests from my clients, and I can't hardly believe that every single time I open it I need to manually ask it to show me unassigned tasks and assign them by hand to myself to get them to appear on the My Tasks view. Anything coming in by email (which is how I'm going to have my clients do it) is unassigned, and Asana gives me absolutely no clue when I log in if an unassigned task is waiting for me to assign it, and it will remain hidden from my to-do list (the My Tasks view) until I do.
There are existing solutions on SO for how to search to find unassigned tasks; those are not what I'm after, as those are how to do manual one-time searches, but I want Asana to tell me the things I need to know about without me either having to remember to manually ask for them every single time I log in, or risking missing something time-sensitive.
Alternatively, if it would either automagically assign mailed-in tasks to me, or let me set my "All Tasks" bookmark to be the default view as soon as I log in, either of these would suffice. I can't find any way of doing any of these things—my goal is that 100% of user-submitted tasks be brought to my attention without me having to remember to look for them (otherwise I could just stick with my dubious previous system of remembering to search my email inboxes.)
If you're using one email address to assign tasks (from a form or whatever) you can go to account settings -> from email and add your email address. That will automatically assign those tasks to you.
Here's the asana docs for it: https://asana.com/guide/help/email/email-to-asana
Otherwise, you can use Zapier (or similar service) to manage creating tasks via email for you if you'd prefer not mess around with the API.

Getting task creator in Asana API

I'm building an Asana API wrapper in python and trying to add functionality to get the creator of a task. As per the suggestion in this question: How to expose asana task creator? I'm loading the stories and inferring it from there but I assumed there'd be a story with the text 'created' as shows up in the web interface but the earliest story I see is always 'added to' then either a tag or project and there is no system story with the text 'created'
Is this the intended behavior of the API?
It's actually not the API but the fact that there actually isn't an event for the task being created - we store the creator and the creation time on the task, so it's kind of redundant (and saves creating a new DB object for every task creation - at scale the little things can add up). In the UI, we show task creation information inline with the other stories, but for the API you should just get that info from the task data itself.

Resources