This template demonstrates how to build a Telegram chatbot powered by AI that can seamlessly hand off conversations to a human agent when needed. It uses n8n’s Human-in-the-Loop (HITL) feature to pause the AI agent, notify a human, and allow the agent to resume after the human returns control. The workflow uses Redis for session state management and LangChain agents for onboarding and after-sales support.
🚀 Features
- Telegram Integration: Start conversations directly with users via Telegram.
- State Management with Redis: Tracks conversation states (
onboarding
,human
,bot
) to control interaction flow. - Onboarding Agent: Collects user details (first name, last name, address, reason for call) before handing over.
- Information Extraction: Automatically extracts structured customer data from free-form conversations.
- Human Handoff: Sends user details and session info to a human agent, pausing the bot until the human responds.
- Seamless Return to Bot: Human agent can transfer control back, injecting context into the AI’s memory for continuity.
- After-Sales Agent: Handles follow-up questions once the human interaction is complete.
- Memory Management: Uses Redis-based chat memory to retain conversation context across different states.
- Flexible Subworkflows: Supports modular handoff logic via subworkflow triggers.