Create a Session-Based Telegram Chatbot with GPT-4o-mini and Google Sheets
    100%
    Automation
    0(0 reviews)
    1330 downloads

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

    NM

    Curated by n8n Markets team

    Last updated: March 8, 2026

    ### 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. 3. Commands for Full Control With intuitive commands like `/new`, `/current`, `/resume`, `/summary`, and `/question`, users can manage sessions easily without needing a web interface. 4. Smart Summarization and Q&A Thanks to OpenAI models, the workflow can summarize entire conversations or answer specific questions about past discussions, saving time and improving the chatbot’s usability. 5. Easy Setup and Scalability By using Google Sheets instead of a database, the workflow is easy to clone, modify, and deploy — ideal for quick prototyping or lightweight production uses. 6. Modular and Extensible Each logical block (new session, get current session, resume, summarize, ask question) is modular, making it easy to extend the workflow with additional features like analytics, personalized greetings, or integrations with CRM systems. --- ### Setup Steps ##### Prerequisites: - Telegram Bot Token: Create via [BotFather](https://core.telegram.org/bots#botfather). - Google Sheets: - Duplicate [this template](https://docs.google.com/spreadsheets/d/1MCJLAqKP0Y7Qr68ZYoSSBeEVyKI1QgAAZnlEiyqkzXo/edit). - Two sheets: `Session` (active/inactive sessions) and `Database` (chat logs). - OpenAI API Key: For GPT-4 responses. ##### Configuration: 1. Telegram Integration: - Add your bot token to the Telegram Trigger and Telegram Send nodes. 2. Google Sheets Setup: - Authenticate the Google Sheets nodes with OAuth. - Ensure sheet names (`Session`, `Database`) and column mappings match the template. 3. OpenAI & Memory: - Add your API key to the OpenAI Chat Model nodes. - Adjust `contextWindowLength` in the Simple Memory node for conversation history length. 4. Testing: - Use Telegram commands to test: - `/new`: Starts a session. - `/question [query]`: Tests AI responses. - `/summary`: Checks summarization. 5. Deployment: - Activate the workflow; the bot will respond to Telegram messages in real-time. --- ### Need help customizing? [Contact me](mailto:info@n3w.it) for consulting and support or add me on [Linkedin](https://www.linkedin.com/in/davideboizza/).

    What's Included

    • Complete n8n workflow template with 0 nodes. Ready to import and customize.

    Requirements

    n8n instance (self-hosted or cloud). credentials.

    How to Use

    1. Download the workflow JSON 2. Import into your n8n instance 3. Configure credentials for 4. Activate and enjoy automation

    How to import this template into n8n

    1. Download the workflow JSON file from this page.
    2. In n8n, open Workflows, create a new workflow and choose Import from File.
    3. Open each node that shows a warning and connect your own credentials.
    4. Run the workflow once manually to check the output before you activate it.
    Included in Pro
    • Importable n8n workflow JSON file
    • Download with Builder Pro or Agency Unlimited
    • Built for n8n v1.0++
    • Setup time: 30-60 min

    Included in Builder Pro — $19/mo, 4,177 premium workflows

    Before you activate

    Templates are reviewed before they are listed. Test with your own credentials and data before running it in production.

    Updated Mar 2026
    v1.0
    SSL
    Secure
    GDPR

    100% Secure Checkout

    Refund requests within 7 days of a new subscription

    Dependencies & Requirements

    Google Sheets
    Data

    ⚠️ 1 service require credentials. Make sure you have accounts set up before importing.

    Reviews

    0

    No reviews yet

    See all 0 reviews ↓
    —

    0 reviews

    5★
    0
    4★
    0
    3★
    0
    2★
    0
    1★
    0

    No reviews yet.

    Questions & Answers

    0

    Log in to ask a question.

    No questions yet. Be the first to ask!

    People Also Bought