Create a session-based Telegram chatbot with GPT-4o-mini and Google Sheets
Needs changesWhat this workflow does
This AI workflow has 31 nodes and runs on Telegram events (message). Along the way it connects OpenAI Chat Model, Telegram and Google Sheets.
How it runs
Trigger: On Telegram events (message).
- Get session (Google Sheets): uses Google Sheets
- Command or text? (Switch): routes items into 5 branches
- Disable previous session (Google Sheets): update
- Send current session (Telegram): uses Telegram
- Get message (Edit Fields (Set)): sets 1 field: text
- Get session (Google Sheets): uses Google Sheets
- Get message (Edit Fields (Set)): sets 1 field: text
- Telegram Chatbot (AI Agent): runs an AI agent, with model: OpenAI Chat Model; memory: Simple Memory
- Set new session (Google Sheets): append
- Trim resume (Code): runs custom JavaScript code
…plus 16 more steps. See the full node list below.
Services it uses
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in Telegram Chatbot (v1.9): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) Telegram Chatbot (v1.9) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (12)
- OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow - Telegram Trigger
n8n-nodes-base.telegramTrigger - Switch
n8n-nodes-base.switch - Google Sheets
n8n-nodes-base.googleSheets - Telegram
n8n-nodes-base.telegram - Summarization Chain
@n8n/n8n-nodes-langchain.chainSummarization - Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm - Edit Fields (Set)
n8n-nodes-base.set - If
n8n-nodes-base.if - Code
n8n-nodes-base.code - AI Agent
@n8n/n8n-nodes-langchain.agent
From the author
How It Works This workflow creates an AI-powered Telegram chatbot with session management, allowing users to: - Start new conversations (/new). - Check current sessions (/current). - Resume past sessions (/resume). - Get summaries (/summary). - Ask questions…