Add Single Task to Todoist

Created an action this morning to prompt for a task and send it to Todoist. It uses the Todoist API, and takes the prompt information only (no draft required) to send a single task over to Todoist. You can find the action here.

The prompt shows a text field where you can enter the task in the normal Todoist manner, using the quick add portion of the Todoist API, including the task, date, project, priority, etc. The note field will allow you to add a note.

You seem to be binding the name con to a Bool with p.Show()

Are you using it ?

What happens if the user cancels the dialog ? Is a task then created with undefined values ?

var con = p.show();

var task = p.fieldValues["task"];
var note = p.fieldValues["note"];

// Call API
var http = HTTP.create(); // create HTTP object
var response = http.request({
  "url": "https://todoist.com/api/v7/quick/add",
  "method": "POST",
  "data": {
    "token":credential.getValue("token"),
    "text":task,
    "note":note
  },
});

Knew I forgot to add something. Got that corrected. The idea is that if the user cancels, then nothing happens. Should be all set now, and the updated action is in the directory.

As a minor footnote, once you have ensured that p.fieldValues is not undefined, it may be less fiddly for people to skip the extra characters in

p.fieldValues["task"] and p.fieldValues["note"]

Simpler and more readable, perhaps, to reference object keys by writing things like:

p.fieldValues.task

and

p.fieldValues.note