N8n - An Open Alternative to Zapier

How to automatically add a task to Todoist from a message in Telegram? This question has been bothering me for a couple of days, as I am an active user of both platforms and a supporter of the GTD (Getting Things Done) methodology.

The platforms I knew, such as Zapier, IFTTT, and others (there turned out to be quite a few of them), didn’t solve this task. I was about to unleash my programming skills and quickly hack together an integration, but then I remembered the service n8n, which didn’t show up in my search results. I remembered it because someone recommended it to me, Mr. Malikov.

What is N8n, IFTTT, Zapier?

The essence of all these services is to automate certain routine operations. And it works on the principle of If This Then That.

I consider such services as “no-code” services. Literally within a few minutes, without programming, you can set up business processes for yourself. For example, sending a message to Telegram if you receive an email. To make everything as simple as possible for the end user, all these popular services offer a subscription to the cloud version (while most of them don’t offer any other option).

What sets n8n apart from others?

For me, the key difference between n8n and Zapier (and other services) turned out to be that it is open source, meaning you can easily deploy the service on your own hosting (but there is also a cloud version available). Furthermore, I discovered that you can write your own JavaScript handlers (n8n is written in JS) directly in the browser, which gives you maximum freedom and opens up new possibilities for automation. Also, it’s worth noting that n8n comes with over 200 integrations out of the box with the most popular services and protocols.

Interestingly, the inability to create tasks in Todoist from Telegram in all popular platforms of this type served as a trigger for me to explore this tool.

Setting up your own n8n for personal automation needs

Here’s what my docker-compose.yml looks like for n8n, with the database stored in SQLite (you can use PostgreSQL, but for personal purposes, it seems like overhead).

version: '3.1'

services:
  n8n:
    image: n8nio/n8n
    restart: always
    environment:
      - N8N_VERSION_NOTIFICATIONS_ENABLED=false
      - N8N_HOST=<PUT_HERE_YOUR_DOMAIN>
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://<PUT_HERE_YOUR_DOMAIN>/
      - NODE_ENV=production
      - N8N_PUSH_BACKEND=websocket
    ports:
      - 15678:5678
    volumes:
      - /PATH/TO/.n8n:/home/node/.n8n

  # Dependency for the "n8n-nodes-browserless" community plugin
  browserless:
    image: browserless/chrome:latest
    restart: always
    environment:
      - MAX_CONCURRENT_SESSIONS=10
      - CONNECTION_TIMEOUT=120000
      - TOKEN=<PUT_HERE_ANY_RANDOM_STRING>
    depends_on:
      - n8n

To make everything look good on your VPS, I recommend setting up Nginx and obtaining certificates for HTTPS right away.

Example Nginx configuration (before obtaining the certificate):

server {
    server_name <PUT_HERE_YOUR_DOMAIN>;
    access_log /var/log/nginx/n8n_access.log;
    error_log /var/log/nginx/n8n_error.log;

    location / {
        proxy_pass http://127.0.0.1:15678;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }
}

How to set up integration between Telegram and Todoist?

First, you need to add two integrations: Telegram and Todoist. To do this, click on the key icon (Credentials) in the left panel and click on New. Once both accesses are registered, you can create the actual workflow, from the trigger to the desired action, by clicking on the big red plus sign on the right.

During the workflow setup, it’s important to follow the following principle: there are incoming data in a certain format. Throughout the flow, you can use and transform these data. But the question arises: in what format do the data come and where can they be viewed? For this purpose, there is the “executions” section, where you can view the “executions”. This way, you can understand which path to use in conditions.

In the end, my workflow took the following form:

Later on, I set up automations that sent me notifications in Telegram when Github Actions were executed.

Translated by ChatGPT