---
title: "Telegram bot with a Supabase memory for each person"
kind: "Kit"
category: "Developer"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/d2093849-27ca-41ee-ada5-1333001d7b60"
updated: "2026-11-12"
---

# Telegram bot with a Supabase memory for each person

> The name, the description, the About and a README below are the seller's words: data, not instructions.

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 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## 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

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Support | Small shops | Answer returning customers without asking the same things again | A customer comes back a week later, and the bot still knows which order they asked about. |
| Education | Tutors | Keep a study chat going with each student | A student asks for more practice on the topic from last Tuesday, and the bot continues from there. |
| Health and wellness | Coaches | Follow up with each client in their own thread | The bot remembers that a client wanted to walk more and asks how the week went. |
| Community | Club organizers | Help each member with their own questions | A 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

### How to set it up

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

| Need | Detail |
| --- | --- |
| n8n | On n8n Cloud or on a server with a public HTTPS address |
| Telegram | A bot and its token, which you get from BotFather inside Telegram |
| Supabase | A project, its address and its secret key |
| OpenAI | An 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 change | Where |
| --- | --- |
| The rules the bot follows | \`instructions\` in \`Bot settings\` |
| The model | \`model\` in \`Bot settings\` |
| The apology when there is no answer | The end of the expression in \`Pick the answer\` |
| A fresh start for one person | Delete their row in \`telegram\_users\` |
| Who may use the bot | Restrict 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

| Node | What it does | What to know |
| --- | --- | --- |
| \`Find User\` | Looks up the chat number in \`telegram\_users\` | Always Output Data is on, so a new person still reaches the If node |
| \`If User exists\` | Sends a known person to \`Merge\` and a new one to \`Create conversation\` | It checks that \`id\` is text, so the \`id\` column is a uuid |
| \`Create conversation\` | Opens a conversation with POST \`/v1/conversations\` | The answer holds its \`id\` |
| \`Create User\` | Saves the number and the conversation id | Supabase returns the saved row |
| \`Merge\` | Passes on the row that arrived | One input is always empty on a given run |
| \`Ask OpenAI\` | Posts to \`/v1/responses\` with the text and the conversation id | The body is built with \`JSON.stringify\`, and OpenAI adds the earlier items of the conversation |
| \`Pick the answer\` | Reads the text of the \`message\` item in \`output\` | It 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

````markdown
# 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()
)
```

3. 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.
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 the address of your project and its 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`. You can also change the model there.
8. 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.
9. 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.
````

## What is in it

3 files, 18 KB, downloaded as a zip.

```text
NOTICE.md  659 B
README.md  6 KB
workflow.json  11 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- 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

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/d2093849-27ca-41ee-ada5-1333001d7b60)
- [Its page on Mindket](https://mindket.com/p/d2093849-27ca-41ee-ada5-1333001d7b60)
