Solution: Create Asana Tasks from "marked text" via "services" on Mac

While being used to the service of OmniFocus, I wanted to create a task from a marked Text (e.g. in Mail or Browser).
Basically you mark the text, press the right mouse button, select the specific “Service” and the task gets created.
Apparently - once you know how - it is quite easy to create such “Service” via “Automator” so therefore I share my findings. Follow those steps:

  1. create an personal access token for the API (
  2. open “Automator” on Mac (e.g. via Spotlight)
  3. select “Service”
  4. once created, select “text” and “any application” on the right top
  5. add an action “Run Apple Script” (
  6. use my code below as a reference for your own adoption
  7. Save the service e.g. “Create Task at Asana”
  8. mark any text, press right mouse button, select “services”, select “Create Task at Asana” -> your task should now appear in your tasks with the marked text in the notes of the task :slight_smile:
    You can also assign a shortcut to this service in OS X via “System Preferences” -> “Keyboard” -> “Shortcuts”
on run {input, parameters}
set prompt to "Please name the task:"
set dialogResult to display dialog prompt ¬
	buttons {"Cancel", "OK"} default button 2 ¬
	default answer "task name"
set theProjectTitle to text returned of dialogResult
set url_text to "curl -X \"POST\" \"\" -H \"Authorization: Bearer YOUR_OWN_PERSONAL_ACCESS_TOKEN_HERE" -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' --data-urlencode \"workspace=YOUR_WORKSPACE_ID_HERE\" --data-urlencode \"assignee=YOUR_USER_ID_HERE\" --data-urlencode \"notes="
set url_text to url_text & input & "\""
set url_text to url_text & " --data-urlencode \"name=" & theProjectTitle & "\""
set response to do shell script url_text
-- display dialog (url_text as text)
-- display dialog (response as text)

end run

Hope this helps.


Just what I was looking for - but I am getting:

“Expected end of line, etc. but found unknown token.”

at: the ’ at:

Probably a backslash for escaping the quotation mark is missing.
Will check later an confirm.

MatJ, I checked and can confirm, that there is a backslash missing after the access token in my example above. Hope it works now for you.

Pefect! Thanks.

Thank you for taking the time to post this. Do you have a way of programming it so that I can select a file and it gets imported into a new task?

Hi Michael,
Sorry for the late reply. Just saw it now.
The way of “programming” it is Apple Automator (App that is pre-installed by Apple on Mac) -> see Screnshots.
You surely also can send files with it to Asana, but I have no experience how to “develop” this.
Best, Frank