Todoist Quick Add Group

I created some (customizable) actions to add tasks to todoist inbox. This Action Group https://actions.getdrafts.com/g/1HK contains my most used ones. Feel free to use them or cuztomize them for your needs.
You’ll need your todoist api token and insert it into the scripts you want to use (get this token from the webinterface in settings under integrations)

If you have any suggestions questions or wishes for new actions - I’ll see what I can do :slight_smile: let’s collect some of the most needed and used actions together!

2 Likes

Great collection, thanks for sharing!

1 Like

Thanks @taglia

I updated the group and simplified some code.

Now you don’t need to put your token into every single action - just in two actions which are included in the others to submit the task.
The two new actions require a taskString/taskStringList and will submit one/multiple Tasks

Hi, I’m looking for a script that would allow me to add multiple items onto a (shared) shopping list in todoist

I want to be able to add multiple items in one go and for them to appear as separate list items.

The todoist shopping action I found in directory doesn’t add to shopping list and adds 1st list as list item and subsequent lites as a comment.

Can’t figure out how to achieve what I’m after.

Alternatively I will try and find a read and write integration between todoist and my native iOS shopping list as that action seems to work perfectly

Many thanks, look forward to your input (so much so I have just registered on this forum just so I can sort it out)

If you look in the Action directory there are already a lot of Todoist actions in there.

https://actions.getdrafts.com/search?utf8=✓&search_type=actions&q=Todoist&button=

If you look at any of the ones processing multiple lines, you can either use the Todoist syntax for your shopping list project or suffix it to each line being processed in one of those scripts.

Thank you, but that doesn’t help because I don’t know how to append it.

For example this solves a problem of each line item being a separate entry

https://actions.getdrafts.com/a/1PI

But there isn’t anything obvious that calls out which list to add it to. For context I’m not a developer, I’m just an advanced user that could tinker with code if it’s obvious. Alas it isn’t.

One of the other actions noted (as does the Todoist documentation) that if you use the hash syntax, you can specify a project inline with the task. That’s what I was referring to above.

Let’s say for example I have a project called “Shopping”. If I have a shopping list like this:

Apple
Banana
Cucumber

You could simply change the list to be like this:

Apple #Shopping
Banana #Shopping
Cucumber #Shopping

But that’s an overhead we don’t need. We could have the script do that.

// create task in Todoist inbox for each line in the draft
const project ="Shopping"

let lines = draft.content.split("\n");

let todoist = Todoist.create();
let ctErrors = 0;

for (let line of lines) {
	if (line.length > 0) {
		let success = todoist.quickAdd(line + " #" + project);
		if (success) {
			console.log("Todoist task created: " + line);
		}
		else {
			ctErrors++;
			console.log("Todoist error: " + todoist.lastError);
		}
	}
}

if (ctErrors > 0) {
	context.fail();
}

This is the script step from the action you referenced above. I’ve made two changes.

One is to create a new constant called project. I’ve set it to be shopping. This is simply a way to put at the top of the code the name of the project I want to add to.

Next I amended the line containing todoist.quickAdd. I appended a space, a hash, and the project to the line variable it is being passed to create a task in Todoist. This is replicating automatically me adding the hash syntax project to every line in the draft at the point of processing.

I ran a quick test and it worked for me.

Does that make sense?

1 Like

Yes this is exactly it!!! Thank you!

This doesn’t seem to work if your supplies replenishment project is called “Shopping list,” though. By this, I mean, simply adding “list” into the quotes above, means that when the action runs, you het multiple lines in the todoist inbox, with the items you submitted, but each followed by ‘#Shopping list.’

So, what would need to be done to accommodate multi-word project titles to get the above to run in the same manner? I have managed to get it to work, as expected, with single-word projects. Cheers.

Correct. That isn’t how the quick add works, but you have to check the Todoist API documentation to find that quick add does not accept spaces in project names.

https://developer.todoist.com/sync/v7/#quick-add-task

That means you can’t use the “convenience” function approach, which for a pre-set shopping list isn’t a big deal, as you probably don’t need to be setting relative priorities, etc. against items.

So swap out the quickAdd function for createTask and populate the project_id with the unique ID of your project, not the name.

E.g.

// create task in Todoist inbox for each line in the draft

const project_id = 123456789;

let lines = draft.content.split("\n");

let todoist = Todoist.create();
let ctErrors = 0;

for (let line of lines)
{
	if (line.length > 0)
	{
		let success = todoist.createTask(
		{
			"content": line,
			"project_id":project_id
		});
		if (success)
		{
			console.log("Todoist task created: " + line);
		}
		else
		{
			ctErrors++;
			console.log("Todoist error: " + todoist.lastError);
		}
	}
}

if (ctErrors > 0)
{
	context.fail();
}

I tested this with my “Alexa Shopping List” project and it worked fine. Just remember it isn’t going to convert any of the quick task syntax, you have to manually work that in with this function.

1 Like

Great stuff. Got this working my end too. Thanks for tour help on this.

hey guys,

the action group will receive a big update in the (more or less) near future. I‘m currently reworking all the actions and also add new stuff.

If you have any requests, what actions you need for todoist, just leave a reply here and I will see what I can do :slight_smile: