Skip to content
FlowHubFluxonLab
A
AI Automationfree

Create a Session-Based Telegram Chatbot with GPT-4o-mini and Google Sheets

by Davide Boizzaadapted from n8n official workflow galleryUpdated Aug 2026
RequiresAAI AgentBBasic LLM ChainCCodeGoogle SheetsGoogle SheetsOpenAI Chat ModelOpenAI Chat ModelSSimple MemorySummarization ChainSummarization ChainTelegramTelegram
Share Post Share
OpenAI Chat ModelOpenAI Chat Mod…MBSimple MemoryGet messageSwCommand or text?Get sessionDisable previous sessionDisable previou…Set new sessionSession activatedSession activat…Send responseUpdate databaseCSSummarization ChainSummarization C…OpenAI Chat Model1OpenAI Chat Mod…OpenAI Chat Model2OpenAI Chat Mod…CLBasic LLM ChainSeGet message1Set to expireIfExist?OKKOCoTrim resumeGet session1CoPrompt + ResumeSend summarySeGet message2CoTrim questionSet new current sessionSet new current…Response + TextCofullTextSend answerSend current sessionSend current se…AgTelegram Chatbot123456789101112131415161718192021222324252627282930
1/5
STEPS · 30
Starts on a Telegram event

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** (/question). Key Components: Session Management**: Uses Google Sheets to track active/expired sessions (storing SESSION IDs and STATE). /new creates a session; /resume reactivates past ones. AI Processing**: OpenAI GPT-4 generates responses with contextual memory (via Simple Memory node). Summarization: Condenses past conversations when requested. Data Logging**: All interactions (prompts/responses) are saved to Google Sheets for audit and retrieval. User Interaction**: Telegram commands trigger specific actions (e.g., /question [query] fetches answers from session history). Main Advantages 1. Multi-session Handling Each user can create, manage, and switch between multiple sessions independently, perfect for organizing different conversations without confusion. 2. Persistent Memory Conversations are stored in Google Sheets, ensuring that chat history and session states are preserved even if the server or n8n instance restarts.

Tags

n8nreference-onlyagentchain-llmchain-summarizationgoogle-sheetslm-chat-open-aimemory-buffer-windowtelegram
Connects
AAI AgentBBasic LLM ChainCCodesheetsGoogle SheetsopenaichatmodelOpenAI Chat ModelSSimple Memory
CategoryAI Automation
Triggermanual
Complexityadvanced
Nodes31
AddedApr 30, 2025

Related workflows

See all AI Automation
AopenaichatmodelS
free

Run a voice-enabled AI assistant on Telegram with OpenAI, Gmail and Notion

Quick overview This workflow turns a Telegram bot into a personal assistant that handles text and voice messages using OpenAI, can read Gmail and Google Calendar, looks up tasks and contacts in Notion, and can draft and send emails with a required approval step in Telegram. How it works Triggers when a new Telegram message is received by your bot. Detects whether the message is a voice note or text, and if it is voice, downloads it from Telegram and transcribes it with OpenAI. Sends the resulting user text to an OpenAI-powered agent that keeps a short conversation memory per chat. When needed, the agent fetches recent emails from Gmail, lists upcoming events from Google Calendar, and pulls tasks or contacts from Notion to answer the request. If the agent decides to send an email, it asks for approval in Telegram and only proceeds after you approve within the time limit. Sends the assistant’s final response back to the same Telegram chat. Setup Create a Telegram bot with @BotFather, add the Telegram credentials in n8n, and use the workflow’s Telegram trigger to connect the bot. Add an OpenAI API credential for both chat responses and voice transcription, and set your preferred model

by Dr. Firas
ACDgmail
free

AI: Summarize podcast episode and enhance using Wikipedia

The workflow automates the process of creating a summarized and enriched podcast digest, which is then sent via email. Note that to use this template, you need to be on n8n version 1.19.4 or later.

by n8n Team
ABembeddingsgooglegeminiW
free

Handle WhatsApp support chats with OpenRouter, Pinecone, and Gemini

Quick overview This template implements a WhatsApp support suite that logs inbound events to a dashboard API, routes conversations through an OpenRouter-powered AI agent with Pinecone RAG and memory, exposes a webhook for human outbound replies, and provides a webhook to summarize recent chats for handoff. How it works Triggers on WhatsApp Cloud API events and routes status updates (sent/delivered/read) to a dashboard API endpoint for storage. For inbound messages, looks up the contact in the dashboard API and normalizes the message into a consistent schema (sender, type, timestamp, and best-effort content). If the message contains media (image/video/audio/document), fetches the WhatsApp media URL, downloads the file, uploads it to the dashboard’s media endpoint, and attaches the resulting media URL and MIME type. Stores inbound messages and reactions in the dashboard API, then checks via the cases endpoint whether the sender already has an open case. If the inbound message is text and no open case is found, queries Pinecone as a tool (using Google Gemini embeddings), uses an OpenRouter chat model with conversation memory to draft a reply or create a new case via the dashboard API,

by Salman Mehboob