---
title: "Telegram chat bot with memory run by an AI agent"
kind: "Kit"
category: "Productivity"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/1c773cb5-067a-4d86-90f9-ba7c36403dea"
updated: "2026-11-12"
---

# Telegram chat bot with memory run by an AI agent

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

An n8n workflow that answers Telegram messages with an AI agent. The agent addresses each person by first name, remembers the last ten messages of the chat, and sends its reply back to the sender.

Telegram chat bot with memory run by an AI agent is an n8n workflow in the Productivity 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 turns a Telegram bot into a chat assistant. When someone messages the bot, an AI agent reads the text, addresses the person by first name and answers. It remembers the last ten messages of the same chat, so a follow-up question makes sense. The answer goes back to the sender in Telegram. Five nodes run it, beside one sticky note.

### Who it suits

People who want an AI assistant inside Telegram, and builders who want a small agent to add tools to. Skip it if you need a bot that does tasks for you, because this copy only talks.

Who uses it, and how

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Personal | Individuals | Ask an assistant from the phone | A user asks the bot to explain a contract term while commuting. |
| Small business | Shop owners | Reword replies to customers | A shop owner pastes a blunt answer and asks for a friendlier one. |
| Education | Tutors | Give a student a patient practice partner | A tutor shares the bot so a student can keep asking questions after class. |
| Development | Builders | Start from an agent with chat and memory | A developer connects a new tool to the agent node and tries it in Telegram. |

You need a little n8n: import a file, add two credentials and create a Telegram bot.

### Where to use it

Any n8n that can reach Telegram and OpenAI will run it. Telegram delivers each message to a web address over HTTPS, so your n8n must be reachable from the internet.

- n8n Cloud: import the file into a new workflow there
- Your own n8n server: the same file, behind a public HTTPS address
- Another chat app: replace the two Telegram nodes with that app’s trigger and send nodes

### 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 and an OpenAI key.

What you need first

| Need | Detail |
| --- | --- |
| n8n | On n8n Cloud or on a server with a public HTTPS address |
| Telegram | A bot made with BotFather, and its token |
| OpenAI | An API key |

1. In n8n, create a workflow, open its menu, choose Import from File and pick `workflow.json`.
2. Add a Telegram credential with your bot’s token and select it in `Listen for incoming events` and `Send final reply`.
3. Add an OpenAI credential and select it in `OpenAI Chat Model`.
4. Publish the workflow, so Telegram has an address to deliver messages to.
5. Send your bot a text message in Telegram and wait for the reply.

### How to use it

Chat with the bot as you would with any assistant. It addresses you by your first name, and a follow-up question sees the earlier messages of the same chat. Only text messages work.

What to change for a different result

| To change | Where |
| --- | --- |
| The bot’s role and manner | The system message in \`AI Agent\` |
| How much it remembers | The context window length in \`Window Buffer Memory\` |
| The model | \`OpenAI Chat Model\` |
| What the bot can do | Add tool nodes to \`AI Agent\` |
| Which updates it reads | \`Updates\` in \`Listen for incoming events\` |

### Example

A user named Lena writes “What does force majeure mean?” to the bot. The agent reads the text and Lena’s first name from the message and replies with a plain explanation that addresses her by name. She then asks “Does that cover a strike?”, and the agent answers with her first question in view.

The memory holds the last ten messages of that chat, so the follow-up does not need to repeat the topic.

### 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. A Telegram bot is an account that a program controls. An AI agent is a node that lets a chat model decide what to do and which tools to call.

**For experts.** `Window Buffer Memory` keys each conversation as `chat_with_` plus the chat ID. It keeps ten messages in the memory of the n8n process, not in a database. The reply goes to the sender’s user ID, which differs from the chat ID in a group chat.

Where to look closer

| Node | What it does | What to know |
| --- | --- | --- |
| \`Listen for incoming events\` | Receives every kind of update | Updates with no \`message\` make the next node fail |
| \`AI Agent\` | Answers the text of the message | Version 1.7, with memory and no tools |
| \`Window Buffer Memory\` | Remembers ten messages per chat | Lives in the n8n process |
| \`Send final reply\` | Sends the answer | Markdown unless you set a parse mode |

### Good to know

The original copy could also draw pictures. That part is gone, and a few other lines were repaired.

- Pictures: the file gave the agent a DALL-E 3 tool and a Telegram tool to send the link. OpenAI’s page, read on 12 November 2026, shows \`dall-e-3\` shut down on 12 May 2026. Mindket’s copy has no image tools
- Model: OpenAI’s page shuts \`gpt-4o\` down on 14 January 2027 and names \`gpt-6-luna\`. That model supports function calling in Chat Completions only with reasoning effort set to none, so Mindket’s copy uses \`gpt-5.6-terra\`
- Text only: a photo, a sticker or an edited message has no \`message.text\`, so that run fails
- Markdown: Telegram’s page says \`\_\`, \`\*\`, the backtick and \`\[\` outside a formatted span must be escaped, so an answer that does not may be refused
- Memory: it sits in the n8n process, so a restart clears it
- Open bot: anyone who finds the bot can message it and use your OpenAI credit
- Not run: Mindket read this copy against n8n’s source and did not run it on a live n8n or with a real bot
- Your data: the messages go to OpenAI, and Telegram holds the chat
- Credentials: the JSON holds none

## README

```markdown
# Telegram chat bot with memory run by an AI agent

An n8n workflow that answers Telegram messages with an AI agent. When someone messages the bot, the agent reads the text, addresses the person by first name and replies. It remembers the last ten messages of the same chat, so a follow-up question makes sense.

## What is inside

- `workflow.json`: the workflow as n8n exports it, 6 nodes. Five of them run and one is a sticky note. It holds no credential.
- `README.md`: these notes.

## What we changed from the original copy

- `OpenAI Chat Model` used `gpt-4o` with a temperature of 0.7 and a frequency penalty of 0.2. OpenAI's deprecation page, read on 12 November 2026, shuts `gpt-4o` down on 14 January 2027 and names `gpt-6-luna`. That model's page says Chat Completions supports function calling only with reasoning effort set to none, and n8n's chat model node offers only low, medium and high. The agent is a tools agent, so the node uses `gpt-5.6-terra`, whose page lists function calling without that limit. It has no temperature or penalty setting, because that page lists neither.
- `Generate image in Dalle` and `Send back an image` are gone. The first called the DALL-E 3 image API, which OpenAI's page lists as shut down on 12 May 2026. The second sent the link that the first returned. The `gpt-image` models that replace DALL-E give back the picture itself and no link: n8n's own OpenAI node treats them that way. The second tool needed a link, so both tools went.
- The last sentence of the system message in `AI Agent`, which told it to send the image link, is removed, since nothing can make a link now.
- The sticky note was titled for the image feature. It now says what the workflow does.
- The credential links are gone, and the file's name is ours.
- Nothing else. The trigger, the memory, the agent's prompt and the reply node are as the file had them.

Mindket read this copy against n8n's source. It was not run on a live n8n and was not connected to a real Telegram bot.

## Before you start

- An n8n instance that can be reached from the internet over HTTPS. Telegram delivers each message to a web address.
- A Telegram bot and its token. You make a bot by chatting with BotFather in Telegram.
- An OpenAI API key.

## Set it up

1. In n8n, create a workflow, open its menu and choose Import from File. Pick `workflow.json`.
2. Add a Telegram credential with your bot's token. Select it in `Listen for incoming events` and `Send final reply`.
3. Add an OpenAI credential and select it in `OpenAI Chat Model`.
4. Publish the workflow, so that Telegram has an address to deliver messages to.
5. Send your bot a text message in Telegram and wait for the reply.

## What happens in a run

1. `Listen for incoming events` starts the run when Telegram delivers an update to the bot. It listens for every kind of update.
2. `AI Agent` takes `message.text` as its prompt. Its system message says it is a helpful assistant talking to a user whose first name comes from the message, and that it should address the user by name every time.
3. `OpenAI Chat Model` writes the answer. `Window Buffer Memory` supplies ten messages of the chat's history, stored under a key made of `chat_with_` and the chat ID.
4. `Send final reply` sends the agent's `output` to the sender's user ID, with the attribution line turned off.

## What to change

- The bot's role and manner: the system message in `AI Agent`.
- How much it remembers: the context window length in `Window Buffer Memory`.
- The model: `OpenAI Chat Model`.
- What the bot can do: add tool nodes to `AI Agent`.
- Which updates it reads: `Updates` in `Listen for incoming events`.
- A different chat app: replace the two Telegram nodes.

## Good to know

- Only text works. A photo, a sticker or an edited message has no `message.text`, so that run fails.
- `Listen for incoming events` is set to every update type. An update that carries no `message`, such as an edited message or a channel post, makes `AI Agent` fail.
- `Send final reply` sends in Markdown unless you set a parse mode. Telegram's page says `_`, `*`, the backtick and `[` outside a formatted span must be escaped, so an answer that does not may be refused. The reply node's error output leads nowhere.
- `Window Buffer Memory` lives in the memory of the n8n process. A restart clears it, and it is not shared between n8n processes.
- The reply goes to the sender's user ID. In a group chat that ID is not the chat ID, which is what the memory uses.
- Anyone who finds the bot can message it and use your OpenAI credit.
- Data: the messages go to OpenAI, and Telegram holds the chat.
- Cost: one model call per message, billed by OpenAI.
```

## What is in it

3 files, 9 KB, downloaded as a zip.

```text
NOTICE.md  652 B
README.md  5 KB
workflow.json  4 KB
```

## Workflow check

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

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

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/1c773cb5-067a-4d86-90f9-ba7c36403dea)
- [Its page on Mindket](https://mindket.com/p/1c773cb5-067a-4d86-90f9-ba7c36403dea)
