Telegram + Google Sheets: chat summaries you can trust
Your Telegram support chat starts out simple. Then the same questions show up again, details get lost in scrollback, and you end up answering from memory (or guessing) because finding the “right” message takes too long.
This is where Telegram Sheets summaries help. Support leads feel it when handoffs go messy. Founders notice it when they’re the fallback for every edge-case. And marketing managers run into the same chaos when community questions pile up.
This workflow turns Telegram chats into structured sessions in Google Sheets, then gives you on-demand summaries and session-based Q&A. You’ll see what it does, why it works, and what you need to run it reliably.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Telegram + Google Sheets: chat summaries you can trust
flowchart LR
subgraph sg0["Get message Flow"]
direction LR
n0@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model", pos: "b", h: 48 }
n1@{ icon: "mdi:memory", form: "rounded", label: "Simple Memory", pos: "b", h: 48 }
n2["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Get message"]
n3@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Command or text?", pos: "b", h: 48 }
n4@{ icon: "mdi:database", form: "rounded", label: "Get session", pos: "b", h: 48 }
n5@{ icon: "mdi:database", form: "rounded", label: "Disable previous session", pos: "b", h: 48 }
n6@{ icon: "mdi:database", form: "rounded", label: "Set new session", pos: "b", h: 48 }
n7["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Session activated"]
n8["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Send response"]
n9@{ icon: "mdi:database", form: "rounded", label: "Update database", pos: "b", h: 48 }
n10@{ icon: "mdi:robot", form: "rounded", label: "Summarization Chain", pos: "b", h: 48 }
n11@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model1", pos: "b", h: 48 }
n12@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model2", pos: "b", h: 48 }
n13@{ icon: "mdi:robot", form: "rounded", label: "Basic LLM Chain", pos: "b", h: 48 }
n14@{ icon: "mdi:swap-vertical", form: "rounded", label: "Get message1", pos: "b", h: 48 }
n15@{ icon: "mdi:database", form: "rounded", label: "Set to expire", pos: "b", h: 48 }
n16@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Exist?", pos: "b", h: 48 }
n17["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>OK"]
n18["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>KO"]
n19["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Trim resume"]
n20@{ icon: "mdi:database", form: "rounded", label: "Get session1", pos: "b", h: 48 }
n21["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Prompt + Resume"]
n22["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Send summary"]
n23@{ icon: "mdi:swap-vertical", form: "rounded", label: "Get message2", pos: "b", h: 48 }
n24["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Trim question"]
n25@{ icon: "mdi:database", form: "rounded", label: "Set new current session", pos: "b", h: 48 }
n26@{ icon: "mdi:database", form: "rounded", label: "Response + Text", pos: "b", h: 48 }
n27["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>fullText"]
n28["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Send answer"]
n29["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Send current session"]
n30@{ icon: "mdi:robot", form: "rounded", label: "Telegram Chatbot", pos: "b", h: 48 }
n16 --> n18
n16 --> n17
n27 --> n13
n2 --> n4
n4 --> n3
n19 --> n15
n14 --> n19
n23 --> n24
n20 --> n21
n8 --> n9
n15 --> n25
n1 -.-> n30
n24 --> n26
n13 --> n28
n21 --> n10
n26 --> n27
n6 --> n7
n3 --> n5
n3 --> n29
n3 --> n14
n3 --> n20
n3 --> n23
n3 --> n30
n30 --> n8
n0 -.-> n30
n11 -.-> n10
n12 -.-> n13
n10 --> n22
n25 --> n16
n5 --> n6
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n2 trigger
class n10,n13,n30 ai
class n0,n11,n12 aiModel
class n1 ai
class n3,n16 decision
class n4,n5,n6,n9,n15,n20,n25,n26 database
class n19,n21,n24,n27 code
classDef customIcon fill:none,stroke:none
class n2,n7,n8,n17,n18,n19,n21,n22,n24,n27,n28,n29 customIcon
The Problem: Telegram Support Gets Amnesia Fast
Telegram is great for fast conversations, but it’s a terrible system of record. A “quick answer” turns into five follow-up messages. Then someone asks the same thing tomorrow, and you can’t remember what you promised, what context mattered, or which version of the truth you gave last time. You search, you scroll, you skim. It’s distracting, and honestly it makes you cautious because you know one wrong reply can create a real support issue.
It adds up fast. Here’s where it breaks down once volume is more than a handful of chats per day.
- You re-answer questions because previous answers are buried in chat history.
- Different teammates reply differently, which means customers get inconsistent guidance.
- Session context gets mixed, so a “billing” chat accidentally inherits “technical” assumptions.
- You have no searchable audit trail when you need to prove what was said and when.
The Solution: Session-Based Telegram Chat Logging + Summaries
This n8n workflow turns your Telegram bot into a session-aware assistant. Every message starts in Telegram, but the “memory” lives in Google Sheets, where sessions are tracked as active or expired. When a user types /new, the workflow creates a fresh session ID and sets it as current. When they use /resume, it reactivates a previous one instead of blending topics together. From there, OpenAI generates replies with contextual memory, and every prompt/response gets logged to a sheet for later search and audit.
When you need a recap, /summary pulls the session’s history from Google Sheets, compacts it, and sends a clean summary back to Telegram. And if someone asks, “What did we decide about pricing?” you can run /question to get an answer grounded in the session log instead of someone’s best guess.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say your team handles about 25 Telegram conversations a week, and you spend maybe 5 minutes per conversation searching old messages or re-explaining prior decisions. That’s roughly 2 hours of pure catch-up. With this workflow, a user runs /summary and gets the recap in under a minute, then /question pulls a specific answer from the same session log. The time cost becomes “send a command, skim a summary,” not “hunt through chat and hope.”
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Telegram for the bot users chat with.
- Google Sheets to store sessions and chat logs.
- OpenAI API key (get it from your OpenAI dashboard).
Skill level: Intermediate. You’ll connect accounts, map a few sheet columns, and test Telegram commands.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A Telegram message triggers everything. The Telegram bot receives a message, then checks Google Sheets to see which session is currently active for that user.
The workflow routes by command. A switch routes requests like /new, /current, /resume, /summary, and /question so each action stays predictable instead of being handled as “free-form chat.”
AI responds with session memory. For normal chat, an AI Agent uses an OpenAI Chat Model plus a compact memory buffer to stay aware of the current session context. That reply goes back to Telegram, and the prompt/response pair is appended to the log in Google Sheets.
Summaries and Q&A pull from stored history. When users request a summary or ask a targeted question, the workflow loads session messages from Google Sheets, assembles the relevant text, and runs a summarization or Q&A chain before sending the result to Telegram.
You can easily modify how long sessions stay “active” or how much history the memory uses based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Telegram Trigger
Start by setting up the Telegram trigger that receives user messages and kicks off the session logic.
- Add and open Telegram Message Trigger.
- Set Updates to
message. - Credential Required: Connect your
telegramApicredentials. - Save the node and ensure the webhook is registered by executing once in test mode.
Step 2: Connect Google Sheets
These nodes manage session state and message history in Google Sheets. Use the same spreadsheet ID across all of them.
- Open Fetch Current Session and set Document ID to
[YOUR_ID]and Sheet Name toSession. - Ensure Filters match
STATE=currentand Options → Return First Match is enabled. - Set Document ID to
[YOUR_ID]and appropriate sheet names for these Google Sheets nodes: Expire Previous Session, Create New Session, Append Chat Log, Mark Session Expired, Set Current Session, Retrieve Session History, Load Session Messages. - Credential Required: Connect your
googleSheetsOAuth2Apicredentials to all Google Sheets nodes listed above.
[YOUR_ID] as a placeholder. Replace it with your actual Google Sheets document ID in every Google Sheets node to avoid empty results.
Step 3: Set Up Command Routing
Route incoming Telegram commands to the correct branch using the switch logic.
- Open Route Command or Text and verify the rules for New session, Current session, Resume session, Summary, and Question using expressions like
{{ $('Telegram Message Trigger').item.json.message.text }}. - Confirm each rule’s Right Value matches the command prefix:
/new,/current,/resume,/summary,/question. - Keep Fallback Output set to
extraso non-command messages route to Telegram AI Agent.
Step 4: Configure Session Management Logic
These nodes expire old sessions, create new ones, and validate session availability.
- In Expire Previous Session, set Operation to
updateand map STATE toexpireand SESSION to{{ $('Fetch Current Session').item.json.SESSION }}. - In Create New Session, set Operation to
append, map STATE tocurrent, and SESSION to{{ $('Telegram Message Trigger').item.json.update_id }}. - In Notify Session Enabled, set Text to
New session activatedand Chat ID to{{ $('Telegram Message Trigger').item.json.message.from.id }}. - Set up Extract Resume Text to assign text from
{{ $('Telegram Message Trigger').item.json.message.text }}, then validate parsing in Parse Resume Command (the code extracts/resume). - In Mark Session Expired and Set Current Session, keep Operation as
updateand map SESSION to{{ $('Fetch Current Session').item.json.SESSION }}and{{ $('Parse Resume Command').item.json.resume }}respectively. - In Check Session Exists, ensure the condition checks whether
{{ $json }}is empty, then routes to Send Session Missing or Send Session Found.
=The current session is {{ $('Fetch Current Session').item.json.SESSION }} to debug session state during testing.
Step 5: Set Up Telegram AI Agent
This branch handles standard messages by invoking an OpenAI-powered agent with memory, then logs the chat.
- Open Telegram AI Agent and set Text to
{{ $('Telegram Message Trigger').item.json.message.text }}. - Set System Message to
Sei un assitente virtuale:\n\nData e ora corrente: {{ $now }}. - Open Compact Memory Buffer and set Session Key to
{{ $('Fetch Current Session').item.json.SESSION }}, Session ID Type tocustomKey, and Context Window Length to100. - Ensure OpenAI Conversation Model is connected to Telegram AI Agent as the language model. Credential Required: Connect your
openAiApicredentials in OpenAI Conversation Model. - In Dispatch Bot Reply, set Text to
{{ $json.output }}and Chat ID to{{ $('Telegram Message Trigger').item.json.message.from.id }}. - In Append Chat Log, map DATE to
{{ $now }}, PROMPT to{{ $('Telegram Message Trigger').item.json.message.text }}, SESSION to{{ $('Fetch Current Session').item.json.SESSION }}, and RESPONSE to{{ $('Telegram AI Agent').item.json.output }}.
Step 6: Set Up Summary and Q&A Chains
This path summarizes a session or answers a question using stored session history.
- In Retrieve Session History and Load Session Messages, filter by SESSION using
{{ $('Fetch Current Session').item.json.SESSION }}. - In Build Summary Context and Assemble Full Text, keep the provided JavaScript that compiles
PROMPTandRESPONSEintofullText. - Configure Summarize Conversation with the prompt
Write a concise summary of the following:\n\n\n"{{ $json.fullText }}"\n\n\nCONCISE SUMMARY:. - Ensure OpenAI Summary Model is connected to Summarize Conversation. Credential Required: Connect your
openAiApicredentials in OpenAI Summary Model. - In Extract Question Text, set text to
{{ $('Telegram Message Trigger').item.json.message.text }}, then let Parse Question Command extract the question via its code block. - In Question Answer Chain, set Text to
Question:\n{{ $json.question }}and keep the message promptYou have to answer the questions that are asked by analyzing the following text:\n\n{{ $json.fullText }}. - Ensure OpenAI Q&A Model is connected to Question Answer Chain. Credential Required: Connect your
openAiApicredentials in OpenAI Q&A Model.
Step 7: Configure Output Nodes
Telegram outputs send status, summary, and Q&A responses back to the user.
- In Deliver Summary, set Text to
{{ $json.response.text }}and Chat ID to{{ $('Build Summary Context').item.json.chat_id }}. - In Deliver Answer, set Text to
{{ $json.text }}and Chat ID to{{ $('Assemble Full Text').item.json.chat_id }}. - In Send Session Found and Send Session Missing, keep the status messages
=The current session is {{ $json.SESSION }}and=This session doesn't exist. - Credential Required: Connect your
telegramApicredentials to all Telegram nodes: Notify Session Enabled, Dispatch Bot Reply, Send Session Found, Send Session Missing, Deliver Summary, Deliver Answer, Report Current Session.
Step 8: Test and Activate Your Workflow
Validate the full workflow by simulating Telegram commands and confirming Google Sheets updates.
- Click Execute Workflow and send a Telegram message like
/newor a normal question to your bot. - Verify a new row appears in the
Sessionsheet and chat entries append to theDatabasesheet via Append Chat Log. - Test
/summaryand/questionto confirm Deliver Summary and Deliver Answer send responses. - When all steps succeed, toggle the workflow to Active for production use.
Common Gotchas
- Google Sheets credentials can expire or need the right permissions. If the workflow stops logging, check the Google Sheets node authentication in n8n first, then confirm the target spreadsheet is still shared to that account.
- If you’re using Wait nodes or external processing, timing can vary. Bump up the wait duration if downstream nodes fail because they’re receiving empty or partial message history.
- OpenAI prompts tend to start generic. Add your brand voice and “what not to say” guidance early, or you will be editing answers forever.
Frequently Asked Questions
About 30 minutes if your bot and sheet are ready.
No. You’ll mostly connect Telegram, Google Sheets, and OpenAI in n8n. The workflow already includes the command parsing, so you’re configuring more than building.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in OpenAI API costs, which are typically a few cents per summary or longer answer.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, but keep it simple at first. You can modify the “Route Command or Text” switch to add new commands, then reuse the existing patterns that write to Sheets and send a Telegram reply. Common tweaks include renaming commands to match your tone, changing what gets stored in the chat log columns, and adjusting the memory window so the bot uses more (or less) history in replies.
Most of the time it’s a bot token issue. Regenerate the token with BotFather, update the Telegram Trigger and Telegram Send credentials in n8n, and retest by sending /current. If it still fails, check that your workflow is active and that Telegram isn’t delivering updates to a different bot instance.
A lot, as long as your Sheets and plan can keep up. On n8n Cloud, your limit is mostly executions per month based on plan, and summaries/Q&A use more compute than basic logging. If you self-host, there’s no execution cap, but performance depends on your server and how big your Google Sheet gets. Practically, most small teams run hundreds of messages a day without drama if the sheet structure stays clean.
Often, yes. Multi-session chat logic, branching commands, and “pull history then summarize it” flows are where n8n tends to feel more natural, and self-hosting is a big deal if you expect volume. Zapier and Make can still work, but they get awkward when you need session state and memory, not just “message in, message out.” The real question is maintenance: if you want something you can extend (new commands, new logging, different models), n8n is usually the calmer choice. If you’re unsure, Talk to an automation expert and sanity-check the approach before you commit.
Once your Telegram chats have sessions, summaries, and a searchable trail in Google Sheets, the whole thing feels lighter. The workflow handles the repetition so you can focus on real support.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.