 asana_project_endpoint = (project_id) ->
   "https://app.asana.com/api/1.0/projects/#{project_id}"
 
-# (Markdown) templates for responses based on response type
+report_error = (msg, err) ->
+  msg.send "Something went wrong: #{err}"
+
+report_invalid_request = (msg, res, body) ->
+  msg.send "Asana returned HTTP #{res.statusCode}: #{JSON.parse(body).errors[0].message}"
+
+
+
+# (Markdown) templates for responses for a task ir project
 task_template = (task) ->
+  t =
+    code:     task.statusCode
+    title:    task.name
+    status:   if task.completed then "[&#10003;]" else "[ ]"
+    assignee: if task.assignee then "#{task.assignee.name}" else "unassigned"
+
+  if task.notes.length > 0
+    split = task.notes.split("\n")
+    t.notes = if split.length > 1 then "#{split[0]} …" else task.notes
+  else
+    t.notes = "(no description)"
+
   """
-  > **#{task.status} #{task.title} (#{task.assignee})**
-  > #{task.notes}
+  > **#{t.status} #{t.title} (#{t.assignee})**
+  > #{t.notes}
   """
 
 project_template = (project) ->
+  p =
+    name:      project.name
+    workspace: project.workspace.name
+
+  if project.notes.length > 0
+    split = project.notes.split("\n")
+    p.notes = if split.length > 1 then "#{split[0]} …" else project.notes
+  else
+    p.notes = "(no description)"
+
   """
-  > **#{project.name} (#{project.workspace})**
-  > #{project.notes}
+  > **#{p.name} (#{p.workspace})**
+  > #{p.notes}
   """
 
-report_error = (msg, err) ->
-  msg.send "Something went wrong: #{err}"
 
 
-get_task = (task_id, robot, msg) ->
+get_task = (task_id, robot, msg, cb) ->
   robot.http(asana_task_endpoint task_id)
     .header("Authorization", asana_auth_header)
     .get() (err, res, body) ->

asana_api_key     = process.env.HUBOT_ASANA_API_KEY
asana_auth_header = 'Basic ' + new Buffer("#{asana_api_key}:").toString('base64')

# Helpers for Asana endpoint URLs
asana_task_endpoint = (task_id) ->
  "https://app.asana.com/api/1.0/tasks/#{task_id}"

        return

      if res.statusCode != 200
        report_invalid_request msg, res, body
        return

      project = JSON.parse(body).data
      cb project
