Notion + ToDoist 2 way sync using postgres

My workflow.

I have no idea how to work it out to make 2-way sync using DB

constant duplicates :frowning:

  • n8n version: 1.18.0
  • Database : Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker):
  • Operating system: Proxmox LXC

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

Hey @Jakub_Pisula,

We have a blog post that I have linked below which goes over the theory and an example of building a 2 way sync although it was created with an old version of n8n the same steps should get you up and running. We also have some examples in our workflow library that may help like this one: Two way sync Pipedrive and MySQL | n8n workflow template

things I would change:

  1. Instead of the Notion:getAll:databasePage, I’d use the Notion triggers pageUpdated (and pageCreated ) and write changes directly to Todoist.
  2. You need to write the Notion page ID to the todoist task, and the task ID to a Notion text property
  3. On a schedule, get all (relevant!) Todoist tasks → update the Notion pages. if error → create notion page.
2 Likes

and now how to update tasks?

Something like this? There might be issues, if changes happen too frequently and simultaneously.

How often are tasks updated, and do you really need to check every 30 seconds?
Is one App the “master task list”?

You’d probably need a way to prevent todoist from undoing changes in notion. Something that checks which version is current after the merge node.

Do you have a way to check when todoist tasks where last updated?

Then you can cross reference it with the last edit datetime from notion (which you also write to a separate field in postgres) and only update entries when they are newer.

Now it should keep only the current version.

you have to add all the necessary fields and expressions to the nodes! they have no functionality in my workflow :slight_smile: .

1 Like

If it works, I can make a tutorial in Polish, but I’ll be happy to tag you :smiley:

no need :slight_smile:
actually, I was thinking about rewriting it :sweat_smile:

Can you share your sql table query to create all the necessary columns and types?

Proszę o to moja baza.

– Table: public.tasks

– DROP TABLE IF EXISTS public.tasks;

CREATE TABLE IF NOT EXISTS public.tasks
(
id uuid NOT NULL,
name text COLLATE pg_catalog.“default”,
url text COLLATE pg_catalog.“default”,
property_task_name text COLLATE pg_catalog.“default”,
property_tags text COLLATE pg_catalog.“default”,
property_assignees text COLLATE pg_catalog.“default”,
property_status text COLLATE pg_catalog.“default”,
property_priority text COLLATE pg_catalog.“default”,
property_summary text COLLATE pg_catalog.“default”,
property_due_start timestamp with time zone,
property_due_end timestamp with time zone,
property_sub_tasks text COLLATE pg_catalog.“default”,
property_is_blocking text COLLATE pg_catalog.“default”,
property_blocked_by text COLLATE pg_catalog.“default”,
property_project text COLLATE pg_catalog.“default”,
id_todoist text COLLATE pg_catalog.“default”,
todoistno boolean,
CONSTRAINT tasks_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.tasks
OWNER to postgres;

I can’t program and I don’t know Java or Python, so GPT chat will help a lot

But n8n is still hosted in Docker on Proxmox, so it’s also easy to install Postgres and pgadmin.

Working with n8n where we store data in Postgres may be easier and later such a database can be used further, e.g. Gogle calendar, we get a Google ID and we can work

1 Like

You’re describing me there :wink:

In Todoist it’s hard to keep the ID from the notion and this automation is built on the basis of this, am I understanding something wrong?

Yes, the alternative is probably to mirror todoist to Postgres and save the notion id to the postgres entry.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.