Skip to content

Capture: Fetch Tasks From Todoist

You end up with one QuickAdd command that pulls tasks from your Todoist account into a note in your vault. This is useful for capturing tasks on the go with your phone, then adding them to Obsidian when you get back to your computer.

  • A Todoist API token. In Todoist, open Settings → Integrations → Developer and copy the API token. The script talks to the Todoist API directly, so you don’t need the Todoist plugin for Obsidian.
  • The Todoist Script, saved in your vault as a .js file, for example scripts/todoistTaskSync.js. Don’t save it inside the .obsidian folder - QuickAdd ignores scripts there.
  • A macro that runs the script, and a Capture choice that writes its output to a note (set up below).

The Todoist Script has three exports, SelectFromAllTasks, GetAllTasksFromProject, and GetAllTasksFromSection.

  • SelectFromAllTasks will prompt you to select tasks from all tasks on your Todoist account,
  • GetAllTasksFromProject will prompt you for a project and get all tasks from that project, and
  • GetAllTasksFromSection will prompt you for a section and get all tasks from that section.

If you run the macro as-is, the script asks you which one to run. To always run one of them, reference it in the Capture format with ::, for example {{MACRO:Todoist::GetAllTasksFromProject}}.

  1. Save the Todoist Script to your vault, for example as scripts/todoistTaskSync.js.

  2. In Settings → QuickAdd, add a Macro choice named Todoist, and add the script to its command list. Add the script by its file name only - don’t add ::GetAllTasksFromProject there, because the script’s settings are only available when the command points at the whole script.

  3. Click the gear (⚙️) next to the script command, and paste your Todoist API token into Todoist API token. QuickAdd keeps it in Obsidian’s secret storage, not in data.json. Leave Complete imported tasks in Todoist ticked, or untick it to leave tasks open in Todoist.

    Todoist script settings

  4. Add a Capture choice with these settings:

    • Capture to: the path to the file where you want to store the tasks.
    • Capture format: Enabled - and in the format, write {{MACRO:Todoist}} to be asked which export to run, or {{MACRO:Todoist::GetAllTasksFromProject}} (or any of the other exports) to run that one directly.

You can make one Capture choice per export, so each has its own command.

The tasks are written in this format: - [ ] <Task Content> 📅 <YYYY-MM-DD>

Which equals: - [ ] Buy groceries 📅 2021-06-27

This task will be recognized by the Tasks plugin for Obsidian, as well. If there isn’t a date set for the task, they’ll simply be entered as - [ ] Buy groceries.

  • “Add your Todoist API token in the Todoist script’s settings”: open the macro, click the gear next to the script command, and paste the token. If the script command’s name ends in ::SomeExport, remove that part so the gear shows the settings.
  • “Todoist rejected the API token (HTTP 401)”: the token is wrong or was reset. Copy it again from Todoist’s Developer settings.
  • “Secret setting … is unavailable. Re-enter it on this device.”: secrets are stored per device. Paste the token again on this device.

This older video shows the general flow of adding a user script to a macro and a Capture choice. It predates the API token setting: instead of setting up the Todoist plugin, paste your token in the script’s settings as described above.

https://user-images.githubusercontent.com/29108628/123511101-bde4a100-d67f-11eb-90c1-5bd146c5d0f2.mp4