Using the API, there is a way to know when a user is @mentioned in a a task?

users
comments

#1

Right now I am using the Event API to subscribe to a project and listen to all events related to it, when someone use @ to mention someone it trigger an event but is handle like a comment, ant the mention will look like https://app.asana.com/0/(id)/(id) , but the id used is not the same user ID that you could retrieve with the API, but nevertheless that link will take you to the user task list, so my doubt is what is that id that appear in the mention link and how I can filter which user is mentioned?


How to resolve a "user id" in a story comment
#2

Hi Victor,

You’ve found a part of our API that is not very intuitive. As you figured out, the mention actually returns the users ‘my tasks’ project: https://app.asana.com/0/(id)/(id). To figure out who the user is, you would then need to look at the memberships of that project. Only the user can only be a member of their ‘my tasks’.

Sorry that this is not very clear or simple!


#3

So, basically the IDs that appear when someone is mentioned and are in this format https://app.asana.com/0/(id)/(id) are the ID of “My Tasks” which is a project, and that project only have one owner ID who is the ID of the user who was mentioned? There is a way of request only the projects where the user is the owner?

Untitled

@Jeff_Schneider do you know if any of this is mentioned somewhere in the documentation ? And thanks for your help :+1:.


#4

Hey Victor,

Yep – you’ve got it. The only way to get the user from a mention is to:

  1. Parse the project id from the mention’s URL
  2. Get that project (which is the user’s ‘my tasks’)
  3. The ‘owner’ of the project is the user from the mention

Unfortunately, this process is not documented explicitly, however, the resources you need to query are documented: projects, users.

Thanks!


#5

@Jeff_Schneider, I need a little more help. Do you know if there is a way to retrieve or get those types projects which are “My Tasks” from specific user?

I was testing getting all the projects but apparently “My Tasks” doesn’t appear.


#6

I’m sorry to say that there is no easy way to get a specific user’s ‘My Tasks’. There are potential workarounds, though they are not great. If you let me know what you’re trying to build, I may be better able to help you find a solution for the project.


#7

I am working on a Chrome Extension, and I would like to subscribe to “My tasks” project so I can be watching when tasks are assigned and so on. I was doing that subscribing to the projects the user already have but there is the scenario where the user doesn’t have tasks so there will be no projects to subscribe or there is the scenario where tasks are assigned without being on a project. So I think the best option is to subscribe to “My task”.


#8

Hey Victor, sorry that it’s not easier to get a user’s “My Tasks”. We hope to improve this in the future.

If you are trying to get all of the tasks assigned to a particular user, you could do something like this:
GET /tasks?assignee=123456&limit=10&workspace=123456. This request gets all tasks assigned to a particular user (you can use a user-id, email, or “me” to select the user). You don’t need to provide a project so it will still get tasks for users that don’t have any projects.

I hope this helps!