Telegram Bot to Human Handoff Automation with n8n

This n8n workflow automates seamless Telegram bot-to-human handoffs by managing conversation states with Redis and AI agents. It reduces wait times and errors by ensuring structured customer onboarding and clear human transfer.
telegramTrigger
redis
switch
+11
Workflow Identifier: 1149
NODES in Use: telegramTrigger, redis, switch, lmChatOpenAi, memoryRedisChat, informationExtractor, agent, toolWorkflow, telegram, code, if, executeWorkflow, executeWorkflowTrigger, memoryManager

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow in n8n manages Telegram messages to switch between an AI chatbot and human agents smoothly.

It solves the problem of confusion and delay when changing from bot to human support during customer chats.

The workflow keeps track of each chat’s state using Redis and uses AI to collect customer details and handle conversations.

The result is faster replies, fewer errors, and a better customer experience.


Who should use this workflow?

Businesses who get many Telegram messages and want to mix AI and human customer support.

This helps when simple questions are answered by a bot but complex requests need a human agent.

Anyone running support with Telegram bots and wanting clear, organized handoffs should use this.


Tools and services used


How the workflow works: Inputs, processing, and output

Inputs

  • New Telegram messages from customers
  • Session data from Redis (state and chat memory)
  • OpenAI responses for AI agents

Processing steps

  • Use Telegram Trigger node to get incoming messages
  • Check Redis for conversation state (bot, human, onboarding) via Redis Get
  • Route message with a Switch node:
    • If “bot”, AI agent responds
    • If “human”, block bot, wait for human agent reply
    • If no state or onboarding, start onboarding flow
  • Onboarding agent gathers name, address, reason for contact using LangChain Information Extractor
  • Store and update session info in Redis with Redis Set
  • When data complete, create a summary and send to human agent for handoff
  • Notify user they speak to a human with Telegram sendAndWait
  • Wait for human reply, then save updated state back to bot with Redis
  • Keep human comments in AI memory to improve future bot responses
  • Allow user to switch back to human with a tool subworkflow
  • Send clear messages when switching or blocking input during handoff

Outputs

  • Smooth conversation transition between AI bot and human agent
  • Structured customer info collected automatically
  • User notifications for clarity on handoffs
  • Enriched AI agent memory for better follow-up replies

Beginner step-by-step: Using this workflow in n8n for production

Import the workflow

  1. Download the workflow file using the Download button on this page.
  2. Open your n8n editor where you want to add this.
  3. Click on “Import from File” and select the downloaded workflow.

Configure credentials and settings

  1. Set up your Telegram Bot API credential in the Telegram Trigger and Telegram nodes.
  2. Connect to your Redis server using the proper credentials in Redis nodes.
  3. Add your OpenAI API Key in LangChain agent nodes.
  4. If needed, update chat ID keys or Telegram channel IDs to match your environment.

Test and activate

  1. Run a test by sending a Telegram message to your bot and see if the workflow triggers.
  2. Check if onboarding collects customer data, and human handoff messages send correctly.
  3. Fix any errors or missing keys before going live.
  4. Activate the workflow to run continuously in production.

For self hosting n8n, consider this resource to run the editor and Redis yourself: self-host n8n.


Customizations

  • Add more customer fields like phone or email by updating the Information Extractor schema.
  • Swap Telegram nodes for Slack or WhatsApp if preferred.
  • Change timeout periods for human agent replies in Telegram sendAndWait nodes.
  • Connect to a CRM by adding HTTP Request or database nodes to log customer data.
  • Edit system messages in Agent nodes to match your company tone and style.

Handling errors and edge cases

  • If Redis Get returns no data, check the key pattern matches handoff_{{chatId}}_state exactly and Redis server is connected.
  • If human replies do not arrive, verify Telegram webhook URLs and that agents monitor messages properly.
  • If AI keeps asking for same info, improve prompt templates in Information Extractor and make sure Redis chat history is clean.
  • Be ready to add alerts or fallback processes if human response times are slow.

Summary of results

✓ Saves time by automating handoff between bot and humans.

✓ Collects customer info automatically during onboarding.

✓ Keeps full context of conversation for better replies.

✓ Sends clear messages so users know when help switches from bot to person.

→ Improves customer support speed and accuracy.


Frequently Asked Questions

The workflow defaults to onboarding mode and starts collecting customer details.
The workflow sends a session summary to the human using a Telegram sendAndWait node.
Yes, Redis stores separate session keys to manage multiple chats simultaneously.
The workflow may time out waiting; users should check webhook settings and consider adding alerts.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free