Mindket

Telegram bot with a Supabase memory for each person

Newversion 1 · updated

Overview

An n8n workflow that gives a Telegram bot a memory for each person. It opens an OpenAI conversation for each new person, saves its id in a Supabase table and continues that conversation on every later message.

Telegram bot with a Supabase memory for each person is an n8n workflow in the Developer category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

At a glance

Runs in
  • n8n Cloud: import the file into a new workflow there
  • Your own n8n server: the same file and steps, once the server has a public HTTPS address
  • Supabase: Supabase Cloud, or a server of your own that n8n can reach
  • Another database: swap the Supabase nodes for the nodes of another database that can store two values

Platform

Connects 3 apps

How it works

Trigger

A Telegram message

It starts each time someone sends a message to your bot, and there is no form:

  • The text of the message
  • The number of the chat

Actions

  1. The person’s chat number is looked up in a Supabase table
  2. For a new person, an OpenAI conversation is opened and its id is saved next to the number
  3. The message goes to OpenAI’s Responses API, together with the conversation id and the rules from Bot settings
  4. The text of the reply is picked out of the answer
  5. The reply is sent back to the same Telegram chat

Result

A Telegram reply that continues the person’s own conversation, and one table row for each person

Integrations

What you need before you start.

Telegram

Chat app

Delivers each message to the workflow and sends the reply back.

NeedsA bot token from BotFather, as a Telegram credential

Supabase

Memory table

Keeps each person’s chat number and conversation id.

NeedsThe project address and its secret key, and a table named telegram_users

OpenAI

AI model

Holds each conversation and writes the replies.

NeedsAn OpenAI API key and some credit

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
10 steps, starting on a Telegram event
AI
No step calls an AI model
Sign-ins
Signs in to: Supabase, OpenAI and Telegram
API keys
No API key is left in the file
Step types
Mindket’s checker reads all 7 of its step types

Read from the workflow’s file, not from a run.

About

What it is

This n8n workflow lets a Telegram bot remember each person who writes to it. A Supabase table holds one row for each person, with their chat number and the id of their OpenAI conversation. A new person gets a new conversation, and a known person continues the old one. OpenAI’s Responses API writes each answer, and Telegram sends it back. Ten nodes do the work, beside five sticky notes.

Who it suits

Builders and small teams who want a Telegram bot that keeps the thread of each chat for days or weeks. You need a Supabase project and an OpenAI key. Skip it if one shared memory for everyone is enough, because a simple chat bot is easier to run.

Who uses it, and how
IndustryWho uses itHow they use itExample
SupportSmall shopsAnswer returning customers without asking the same things againA customer comes back a week later, and the bot still knows which order they asked about.
EducationTutorsKeep a study chat going with each studentA student asks for more practice on the topic from last Tuesday, and the bot continues from there.
Health and wellnessCoachesFollow up with each client in their own threadThe bot remembers that a client wanted to walk more and asks how the week went.
CommunityClub organizersHelp each member with their own questionsA member asks a follow-up about an event, and the bot knows which event they mean.

You need some n8n: import a file, add four credentials, run two short queries and edit one text.

Where to use it

Any n8n with a public HTTPS address can run it, because Telegram sends each message to that address.

  • n8n Cloud: import the file into a new workflow there
  • Your own n8n server: the same file and steps, once the server has a public HTTPS address
  • Supabase: Supabase Cloud, or a server of your own that n8n can reach
  • Another database: swap the Supabase nodes for the nodes of another database that can store two values

Setup

Download saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. You need a Telegram bot token, a Supabase project and an OpenAI API key.

What you need first
NeedDetail
n8nOn n8n Cloud or on a server with a public HTTPS address
TelegramA bot and its token, which you get from BotFather inside Telegram
SupabaseA project, its address and its secret key
OpenAIAn API key and some credit
  1. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  2. In the Supabase SQL editor, run the query in the notes that make the table telegram_users: an id that is a uuid, a telegram_id, an openai_conversation_id and a creation time.
  3. Run a second query that turns on Row Level Security for the table. The secret key that n8n uses still works.
  4. In Get New Message, add a Telegram credential with your bot token. Select the same credential in Send Message to User.
  5. In Find User and Create User, add a Supabase credential with your project address and secret key.
  6. In Create conversation and Ask OpenAI, add an OpenAI credential with your API key.
  7. Open Bot settings and rewrite the rules in instructions.
  8. Press Test workflow and send a message to your bot. A row appears in telegram_users, and a second message continues the chat with no new row.
  9. Turn the workflow on, so that the bot keeps answering when you are away.

How to use it

Once the workflow is on, it answers by itself. Each message that someone sends to the bot starts a run, and one reply goes back. A person who writes for the first time adds one row to the table.

What to change for a different result
To changeWhere
The rules the bot followsinstructions in Bot settings
The modelmodel in Bot settings
The apology when there is no answerThe end of the expression in Pick the answer
A fresh start for one personDelete their row in telegram_users
Who may use the botRestrict to User IDs in Get New Message

Example

A tutor runs a small English class on Telegram.

A student writes “Can we practise the past tense again?”. The workflow finds no row for her number, opens a conversation and saves its id. The bot answers with three short exercises. Two days later she writes “I finished the last ones”. The row is there now, so the bot continues the same conversation and knows which exercises she means. Check what the bot teaches before you rely on it, because the answers come from a model.

For newcomers and experts

If you are new. n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. Supabase is an online database, a bit like a spreadsheet that programs can read. This workflow keeps a list of who wrote to your bot and which conversation belongs to each person. Press Test workflow and write to the bot before you turn it on.

For experts. The memory lives at OpenAI, and the table only maps a chat number to a conversation id, so the workflow never stores the chat text itself.

Where to look closer
NodeWhat it doesWhat to know
Find UserLooks up the chat number in telegram_usersAlways Output Data is on, so a new person still reaches the If node
If User existsSends a known person to Merge and a new one to Create conversationIt checks that id is text, so the id column is a uuid
Create conversationOpens a conversation with POST /v1/conversationsThe answer holds its id
Create UserSaves the number and the conversation idSupabase returns the saved row
MergePasses on the row that arrivedOne input is always empty on a given run
Ask OpenAIPosts to /v1/responses with the text and the conversation idThe body is built with JSON.stringify, and OpenAI adds the earlier items of the conversation
Pick the answerReads the text of the message item in outputIt skips reasoning items and writes a short apology when there is no text

Good to know

The original copy ran on the Assistants API, which OpenAI has shut down, so this copy moves it to the Responses and Conversations API.

  • API: OpenAI’s deprecations page, read on 12 November 2026, gives 26 August 2026 as the shutdown date of the Assistants API and names the Responses API and the Conversations API as its replacements
  • Rules: the original copy named an assistant that belonged to its author. The rules and the model now sit in Bot settings
  • Column: openai_thread_id is now openai_conversation_id, and the table query is rewritten with a uuid id
  • Memory: OpenAI’s guide, read on 12 November 2026, says conversation objects and their items are not subject to the 30 day TTL.
  • Cost: each answer sends all earlier items of the conversation as input, so a long chat costs more for each new message. The model gpt-6-luna costs 0.10 US dollars per million input tokens and 0.50 per million output tokens.
  • Instructions: OpenAI’s reference does not say whether they carry over inside a conversation, so this copy sends them with every message
  • Open bot: anyone who finds the bot can spend your OpenAI credit. Restrict to User IDs in Get New Message limits it, and works on node version 1.2 and later, which this file uses
  • Text only: a photo or a voice message has no text, so OpenAI refuses the call
  • Secret key: the Supabase secret key gives full access to your data, so keep it in the n8n credential
  • Your data: each message goes to OpenAI, and the chat number and the conversation id are stored in your Supabase table
  • Not run: Mindket did not call Telegram, Supabase or OpenAI to test this file, and ran it in a test runner with stand-in answers
  • Credentials: the JSON holds none, and its author’s assistant id is gone

README and files

README

Telegram bot with a Supabase memory for each person

An n8n workflow that gives a Telegram bot a memory for each person. When someone writes to the bot for the first time, the
workflow opens an OpenAI conversation for them and saves its id in a Supabase table, next to their chat number. Every
later message continues the same conversation, so the bot remembers the chat after a restart or a new day.

What is inside

  • workflow.json: the workflow as n8n exports it, ten nodes and five sticky notes. It holds no credential.
  • README.md: these notes.

What we changed from the original copy

  • The original copy used OpenAI's Assistants API, with a thread, a message, a run and a list of messages for each reply.
    OpenAI's deprecations page, read on 12 November 2026, gives 26 August 2026 as the shutdown date of the Assistants API and
    names the Responses API and the Conversations API as its replacements. This copy uses them.
  • Create conversation replaces the call that made a thread. Ask OpenAI replaces the three calls that sent the message,
    started the run and read the messages back. One call to /v1/responses returns the answer, and the new node
    Pick the answer reads it.
  • The original copy named an assistant that belonged to its author, and the assistant held the bot's rules. The rules now sit in a
    new node, Bot settings, together with the model name, which is gpt-6-luna.
  • The Supabase column openai_thread_id is now openai_conversation_id, and the table query is rewritten. The id column
    is a uuid on purpose, because If User exists checks that id is text.
  • Get New Message is now on node version 1.2, which can limit who may use the bot. See the first item under Good to know.
  • The eight sticky notes linked to their author's pages. Five new notes replace them, with no outside links.
  • Every credential reference is removed, so you pick your own.

Before you start

  • An n8n instance with a public HTTPS address. Telegram delivers updates by an HTTPS POST to the webhook address.
  • A Telegram bot and its token. You make one by chatting with BotFather inside Telegram.
  • A Supabase project. Its address and its secret key go into one n8n credential.
  • An OpenAI API key with some credit.

Set it up

  1. In n8n, create a workflow, open its menu and choose Import from File. Pick workflow.json.
  2. In the Supabase SQL editor, run this query to make the table:
create table public.telegram_users (
  id uuid primary key default gen_random_uuid(),
  telegram_id bigint not null unique,
  openai_conversation_id text not null,
  created_at timestamptz not null default now()
)
  1. Run a second query, alter table public.telegram_users enable row level security. The table is then closed to the public
    keys of your project, and the secret key that n8n uses still works.
  2. In Get New Message, add a Telegram credential with your bot token. Select the same credential in Send Message to User.
  3. In Find User and Create User, add a Supabase credential with the address of your project and its secret key.
  4. In Create conversation and Ask OpenAI, add an OpenAI credential with your API key.
  5. Open Bot settings and rewrite the rules in instructions. You can also change the model there.
  6. Press Test workflow and send a message to your bot. A row appears in telegram_users. Send a second message and the bot
    continues the chat, with no new row.
  7. Turn the workflow on, so that the bot keeps answering when you are away.

How a run goes

  1. Get New Message starts the run when someone sends a message to your bot.
  2. Find User looks for the person's chat number in telegram_users. It outputs an empty item when there is no row.
  3. If User exists sends a known person straight to Merge.
  4. For a new person, Create conversation opens a conversation at OpenAI, and Create User saves its id with their chat number.
    The saved row goes to the second input of Merge.
  5. Merge passes on whichever row arrived, with the conversation id in openai_conversation_id.
  6. Bot settings adds the model name and the rules.
  7. Ask OpenAI sends the message text with the conversation id. OpenAI adds the earlier items of that conversation to the input.
  8. Pick the answer takes the text of the model's reply. If there is none, it writes a short apology.
  9. Send Message to User sends it to the chat the message came from.

Change the look

  • The rules and the model: Bot settings.
  • The apology: the text at the end of the expression in Pick the answer.
  • A fresh start for one person: delete their row in telegram_users. Their next message opens a new conversation.
  • Who may use the bot: see the first item under Good to know.

Good to know

  • Anyone who finds the bot can write to it and spend your OpenAI credit. To limit it, open Get New Message, add the field
    Restrict to User IDs under Additional Fields and list the Telegram user numbers that may use it. Messages from other
    people are then dropped with no error. The field is enforced on node version 1.2 and later.
  • The memory lives at OpenAI. OpenAI's guide on conversation state, read on 12 November 2026, says that conversation objects and their items are not subject to the 30 day TTL.
  • Each answer sends all earlier items of that conversation as input, so a long chat costs more for each new message. On
    OpenAI's model page, gpt-6-luna costs 0.10 US dollars per million input tokens and 0.50 per million output tokens.
  • OpenAI's reference does not say whether instructions carry over inside a conversation, so this copy sends them with
    every message.
  • The bot reads text only. A photo or a voice message has no text, so OpenAI refuses the call and the sender gets no reply.
  • Replies go out in Telegram's Markdown mode, which is the n8n default. A lone _ or * in an answer can make Telegram
    refuse the message.
  • The secret key of Supabase gives full access to your data. Keep it in the n8n credential and nowhere else.
  • Your data: each message goes to OpenAI, and the chat number and conversation id are stored in your Supabase table.
  • Not run: we did not call Telegram, Supabase or OpenAI to test this file. We ran it in a test runner with stand-in answers
    for a new person, a known person and a reply with no text.
  • Credentials: the JSON holds none.
Files
NOTICE.md  659 B
README.md  6 KB
workflow.json  11 KB

3 files, 18 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-12

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

anaksor-ocr

Sokheng · Kit

Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…

New

Qwen2.5-7B-Instruct as GGUF files in eight quantization sizes, to chat with locally through llama.cpp. For people who want a capable 7.6B model on their own co…

New

ACE-Step 1.5 XL SFT

ACE-Step · Kit

Generates music from text with a 4B diffusion decoder, 50 steps and guidance control, aiming for higher audio quality than the base. For creators with a GPU of…

New

Similar in Developer

See all in Developer

Claude Code Skills & Plugins

alirezarezvani · Skill

Adds 411 ready-made skills for Claude Code and other coding agents, grouped by role from engineering and product to marketing, finance and compliance. Installs…

New29.8k

buzz

block · Kit

Self-hostable workspace where people and AI agents share the same rooms, built on a Nostr relay that logs every action as a signed event. For teams that want t…

New37.3k

plannotator

backnotprop · Kit

Opens your AI coding agent's plans, specs and code changes in a browser so you can annotate or comment on them and send the feedback straight back to the agent.

New10.5k