This workflow contains community nodes that are only compatible with the self-hosted version of n8n.
Deliver seamless, AI-driven customer support on Telegram and WhatsApp—powered by GPT-4 Turbo and n8n.
🌟 Key Features
- Unified Messaging: Receive and normalize messages from both Telegram (via Bot Trigger) and WhatsApp (via Webhook).
- Contextual AI Responses: Build customer context from Google Sheets, then craft personalized replies with GPT-4 Turbo.
- Smart Routing: Automatically detect platform and send replies with platform-appropriate formatting (HTML for Telegram, plain for WhatsApp).
- Intent Detection & Escalation: Flag orders, appointments or complex queries and trigger Slack notifications for human handoff.
- Comprehensive Logging: Append every interaction to a “conversations” sheet and upsert customer profiles in a “customers” sheet.
📋 Prerequisites
- n8n instance (self-hosted or n8n Cloud)
- Credentials:
- OpenAI API key
- Telegram Bot Token
- WhatsApp Business API credentials (
WHATSAPP_PHONE_ID
)
- Google Sheets service-account credentials
- Slack Incoming Webhook URL
- Google Sheets Setup:
- customers sheet with columns:
user_id
, user_name
, previousOrders
, lastInteraction
, preferences
, conversationHistory
- conversations sheet with columns:
user_id
, user_name
, platform
, message
, ai_response
, timestamp
, needs_escalation
, is_order
, is_appointment
🚀 Setup & Usage
- Import the provided JSON into your n8n editor.
- Configure each node’s credentials in n8n’s Credentials panel.
- Set the following Workflow Variables:
GOOGLE_SHEET_ID
WHATSAPP_PHONE_ID
- Activate the Telegram Bot Trigger and WhatsApp Webhook nodes.
- Test by messaging your bot on Telegram and WhatsApp.
🔍 How It Works
- Trigger: Listens for new Telegram updates or WhatsApp webhook calls.
- Normalize Message: Standardizes payload into
{ user_id, user_name, message_text, platform, chat_id, timestamp }
.
- Get Customer Data: Reads from “customers” sheet to fetch past history and order count.
- Build AI Context: Merges incoming message with customer info and history.
- AI Assistant: Sends context to GPT-4 Turbo (temperature 0.8, maxTokens 800).
- Process Response: Cleans formatting, identifies intents (order, appointment), and sets escalation flags.
- Platform Router: Routes reply to the appropriate “Send Telegram” or “Send WhatsApp” node.
- Log Conversation: Appends each message and response to the “conversations” sheet.
- Update Customer: Increments
previousOrders
, updates last interaction timestamp, and saves a snippet of the latest message.
- Escalation: If flagged, posts a formatted alert to your Slack channel for immediate attention.
Empower your business with 24/7 AI-powered support—save time, increase conversions, and ensure no customer inquiry goes unanswered.