@mention a user in a story on a task

I’m trying to figure out how to mention another user in a story on a task. From what I can tell, the way to do this is by linking the user you want to mention’s task list. However, as far as I can tell it is not possible to actually get this information for a separate user (see: Get a user's task list -- forbidden Error - #2 by Carlos_Guido_Guido)

There is a separate thread here: Any way to create User @mentions using API? that has gone stale, a suggestion there is to get a list of users in the workspace and then pull the task list id from there, however as far as I can tell the user’s task list id is not returned in this request.

Given these constraints, is it impossible to mention a user in a story if the origin is from the API? This seems like some pretty basic functionality that the API should be able to support, the commenting API’s use is pretty severely limited without this capability.

Hi @Aaron_Wilson,

You can’t retrieve the actual items contained in the user task list of another user, but you can get the gid of a user’s user task list via this endpoint: Asana

1 Like

Hey @Phil_Seeman, that call gives me a 403 forbidden when I call it with another user’s id

Well darn, I was sure that would work, but I guess not! :sob:

1 Like

I was able to find a workaround although it’s not exactly ideal. You can get the list of user’s workspace memberships, then filter it to the correct workspace, then get that specific workspace membership which returns the gid for the user’s task list.

https://developers.asana.com/docs/get-workspace-memberships-for-a-user

https://developers.asana.com/docs/workspace-memberships

Good work, @Aaron_Wilson!

1 Like

Great work!

Hi,

I’ve found through experimentation that you can accomplish a user-mention by adding an anchor tag with a couple of attributes as below in the story. Replace user-id with the gid for the user in question.

<a data-asana-gid="user-id" data-asana-type="user"></a>

I’m pretty user you don’t even need the “data-asana-type” attribute.

Hi @Ben_Hines and welcome to the forum!

This is documented here:
https://developers.asana.com/docs/writing-rich-text

Thanks @Phil_Seeman. That would have been good to point out on the original post. Appreciate the reply!

Pretty sure that functionality didn’t exist at the time of the initial post; it’s relatively new…

It’s pretty straightforward actually.
I reverse engineered it, grabbed a a story I created manually via the API

As long as you have the user gid, all you have to do is;
https://app.asana.com/0/"user_gid" Good Morning

will return

@user good morning

PLEASE HALP

I’ve been grinding on this for hours and haven’t managed to get it to work. I’m sending a custom JSON request with a ‘Webhooks by Zapier’ action as part of a larger Zapier automation. It feels like I’ve tried every format/combination/syntax variant suggested here—and then some—and nothing is working.

Here’s a call that results in the posting of a rich text comment (this is working just fine).
URL I’m using: https://app.asana.com/api/1.0/tasks/**{task-gid}**/stories

{
  "data": {
    "html_text": "<body>This is a <strong>test</strong>.</body>"
  }
}

Now let’s say I want to @-mention my colleague John Appleseed (user gid=123456789) after the sentence I wrote. Could someone please spell out exactly how the whole call would be written?

@Alex_Russell-Falla1,

I haven’t ever set an @mention myself, but per the API documentation here, the format should be
<a data-asana-gid="123"/>.

So in your example:

{
  "data": {
    "html_text": "<body>This is a <strong>test</strong>.<a data-asana-gid="123456789"/></body>"
   }
}

Does that work?