n8n

How to Automate Telegram Support with Google Sheets?

Run an AI chat assistant on Telegram that keeps session context and logs every chat to Google Sheets. Support teams can start fresh chats, resume older threads, and request quick summaries without leaving Telegram. It fits help desks, community managers, and sales reps who need fast answers and clean records.

Incoming Telegram messages start the flow. A router checks for commands like new, current, resume, summary, and question, then sends each path to the right logic. Session state lives in a Google Sheets tab, where old sessions get marked to expire and a new current session is set per user. When a user asks a question, the message and recent memory go to an OpenAI chat model through LLM and summarization steps. The reply goes back to Telegram, and a database sheet captures date, prompt, response, and session for tracking and analytics.

You only need a Telegram bot, an OpenAI API key, and a copy of the Google Sheet to run it. Most teams see faster replies, fewer context switches, and complete chat logs without extra typing. It suits tier one support, pre sales chat, and community Q and A where context and history matter.

What are the key features?

  • Telegram trigger listens for new messages and commands in real time
  • Command router detects slash commands and routes to new, current, resume, summary, or question paths
  • Google Sheets session table sets current sessions and marks old ones to expire
  • Memory buffer keeps the last 100 messages using the user session key for context
  • OpenAI chat model generates answers and a summarization chain produces short recaps
  • Database logging appends date, prompt, response, and session to a reporting sheet
  • Resume flow trims older text, reloads context, and rebuilds the conversation for follow ups

What are the benefits?

  • Reduce manual session tracking from 30 minutes to 1 minute per chat
  • Automate 90 percent of chat logging with Google Sheets updates
  • Improve answer consistency with AI summaries of each session
  • Handle up to 5 times more concurrent chats with session memory
  • Connect Telegram, OpenAI, and Google Sheets in one workflow

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Telegram, Google Sheets and OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. Create a Telegram bot with BotFather and copy the bot token. In the n8n credentials manager, create Telegram credentials and paste the token. Select these credentials on the Telegram Trigger and all Telegram Send nodes.
  4. Make a copy of the Google Sheets template. In the n8n credentials manager, create Google Sheets OAuth2 credentials and connect your Google account. Open each Google Sheets node and select your credentials, then set the document ID and the correct sheet tabs for Sessions and Database.
  5. Get your OpenAI API key from the OpenAI dashboard. In n8n, create OpenAI credentials using the API key. Open all OpenAI nodes and select these credentials and the desired model.
  6. Check the session nodes. In Get session, confirm the filter uses STATE equals current. In Disable previous session and Set new session, verify the sheet name and column mappings for SESSION and STATE.
  7. Verify memory settings. In the Simple Memory node, confirm the session key references the SESSION from the Get session node and the context window length is set as needed.
  8. Enable the workflow. In Telegram, send /start to your bot, then send /new. You should receive the Session activated message in Telegram.
  9. Test a question with /question followed by your text. Confirm a reply is returned, and check the Database sheet for a new row with date, prompt, response, and session.
  10. Send /summary to receive a short recap of the conversation. If the message is too long, adjust trim nodes or the summarization settings.
  11. Troubleshoot common issues. If no messages arrive, make sure the bot is started in Telegram and the credentials are valid. If Google Sheets returns a permission error, confirm the spreadsheet is in the connected Google account. If OpenAI errors, check the API key and model availability. On self hosted n8n, ensure a public URL is reachable by Telegram.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Sheets

Sign up

Free: $0 (Google Sheets API usage has no additional cost; quota limits apply)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.