1 Create the database
You need an empty PostgreSQL database, and a database user allowed to create tables in it. The tables, meaning the shelves the bot stores things on, come at step 6 in one click, with no terminal. Three ways to get the database:
A. A separate database on a PostgreSQL server you already have
If your n8n already runs on PostgreSQL, or you have a PostgreSQL server elsewhere, create a
database just for the bot instead of putting its tables in n8n's own: you can back it up,
move it or drop it without touching n8n. Connect as an admin (psql, pgAdmin or
DBeaver) and run once:
CREATE USER taskmaster WITH PASSWORD 'a-long-password'; CREATE DATABASE taskmaster OWNER taskmaster;
In the Postgres account credential of step 2: that server's host, port
5432, database taskmaster, user taskmaster and that
password.
B. A hosted database, free to start
It is the only option if you are on n8n Cloud. Two well-known PostgreSQL services:
- Neon: 0.5 GB free. The database sleeps after 5 minutes without activity and wakes up on its own at the next message, with a short delay. Our first choice.
- Supabase: 500 MB free, but a free project with too little activity is paused after a week. A quiet bot may get cut off.
Create a project, copy the host, database, user and password into Postgres account,
and set SSL to Require. On Supabase, if the direct connection fails, use the
Session pooler settings.
C. Everything on your own server or computer, with Docker
n8n already installed? One command adds a database reserved for the bot:
docker run -d --name taskmaster-db --restart unless-stopped \ -e POSTGRES_USER=taskmaster \ -e POSTGRES_PASSWORD=a-long-password \ -e POSTGRES_DB=taskmaster \ -v taskmaster-db:/var/lib/postgresql/data \ -p 127.0.0.1:5433:5432 \ postgres:16
If n8n runs directly on the machine, the host is 127.0.0.1 and the port
5433. If n8n also runs in Docker, put both on the same network
(docker network connect <n8n network> taskmaster-db) and use host
taskmaster-db, port 5432.
Starting from scratch? This file installs n8n and the bot's database together.
Save it as docker-compose.yml in an empty folder, replace the address, the token
and the password, then run docker compose up -d. The bot's database stays
separate from n8n's own data.
services:
n8n:
image: docker.n8n.io/n8nio/n8n
restart: unless-stopped
ports:
- "5678:5678"
environment:
- WEBHOOK_URL=https://n8n.your-domain.com/
- BOT_TOKEN=the-token-from-botfather
- N8N_BLOCK_ENV_ACCESS_IN_NODE=false
- GENERIC_TIMEZONE=Europe/Zurich
- TZ=Europe/Zurich
volumes:
- n8n_data:/home/node/.n8n
taskmaster-db:
image: postgres:16
restart: unless-stopped
environment:
- POSTGRES_USER=taskmaster
- POSTGRES_PASSWORD=a-long-password
- POSTGRES_DB=taskmaster
volumes:
- taskmaster_db:/var/lib/postgresql/data
volumes:
n8n_data:
taskmaster_db:
n8n opens on http://localhost:5678. In Postgres account: host
taskmaster-db, port 5432, database and user taskmaster.
Telegram has to reach this n8n at a public https address: see "Where to run n8n"
above.