This workflow corresponds to n8n.io template #17285 — we link there as the canonical source.
This workflow follows the Error Trigger → Gmail recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "bVxn7MKfNJKpfz54",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "AI Real Estate Lead Qualification & Customer Support System",
"tags": [],
"nodes": [
{
"id": "c2571290-d388-4ede-bf37-1840c6d2ecb3",
"name": "\ud83d\udccc Overview \u2013 How This Workflow Works",
"type": "n8n-nodes-base.stickyNote",
"position": [
-240,
1680
],
"parameters": {
"width": 872,
"height": 596,
"content": "## \ud83c\udfe0 RealtyOS AI v2 \u2013 Real Estate Lead Qualification & EMI Assistant\n\n### How it works\nEvery message sent to the Telegram bot is first classified by GPT-4o-mini into one of three intents \u2014 lead qualification, EMI simulation, or support query \u2014 regardless of the language used. Lead messages are scored 0\u2013100, logged to Google Sheets, and hot leads (70+) trigger an immediate email to the agent. EMI queries get loan parameters extracted, a precise monthly EMI calculated in code, and a friendly result sent back in the user's own language. Support questions are answered directly by AI where possible; unresolvable ones are logged and escalated to Slack.\n\n### Setup steps\n1. Connect your **Telegram Bot API** credential to all Telegram nodes.\n2. Connect **OpenAI API** to the four AI nodes (classification, lead scoring, EMI reply, support query).\n3. Connect **Google Sheets OAuth2** and create a sheet with tabs: `Leads`, `EMI_Simulations`, `Support_Tickets`.\n4. Replace `YOUR_GOOGLE_SHEET_ID` in every Google Sheets node.\n5. Connect **Gmail OAuth2** and update the hot-lead email recipient in the Notify Agent node.\n6. Connect **Slack OAuth2**, set `YOUR_SLACK_CHANNEL_ID` in the escalation and error alert nodes.\n7. Activate the Telegram trigger and test with a sample message in English or any Indian language."
},
"typeVersion": 1
},
{
"id": "28c23aff-8253-4886-88fd-60ca2aca6bbd",
"name": "Section \u2013 Message Intake & Classification",
"type": "n8n-nodes-base.stickyNote",
"position": [
400,
2624
],
"parameters": {
"color": 7,
"width": 1268,
"height": 456,
"content": "## \ud83d\udce9 Message Intake & Intent Classification\nReceives every Telegram message, normalises the sender details, then uses GPT-4o-mini to detect the message language and classify the intent as lead qualification, EMI simulation, or support query before routing."
},
"typeVersion": 1
},
{
"id": "94c72436-04df-48c3-8dd7-077825e91627",
"name": "Section \u2013 Lead Qualification & Agent Routing",
"type": "n8n-nodes-base.stickyNote",
"position": [
1744,
1872
],
"parameters": {
"color": 7,
"width": 1312,
"height": 696,
"content": "## \ud83c\udfe1 Lead Qualification & Agent Routing\nExtracts budget, location, property type, urgency, and a lead score. Logs every lead to Google Sheets. Scores 70+ trigger an immediate Gmail alert to the agent and a Telegram message telling the customer an expert is connecting. Lower scores get a nurturing reply."
},
"typeVersion": 1
},
{
"id": "30619a40-72ba-4ae2-8715-c8b819f893d0",
"name": "Section \u2013 EMI Simulation",
"type": "n8n-nodes-base.stickyNote",
"position": [
1824,
2640
],
"parameters": {
"color": 7,
"width": 1600,
"height": 504,
"content": "## \ud83d\udcb0 EMI Simulation\nExtracts loan amount, interest rate, and tenure from the user's message (defaulting sensibly if missing), calculates the exact monthly EMI in code, logs it to the EMI_Simulations sheet, and returns a formatted breakdown in the user's own language."
},
"typeVersion": 1
},
{
"id": "727297f0-92b2-4d23-a349-aad38b30993f",
"name": "Section \u2013 Support Query & Escalation",
"type": "n8n-nodes-base.stickyNote",
"position": [
1712,
3280
],
"parameters": {
"color": 7,
"width": 1360,
"height": 728,
"content": "## \ud83c\udfab Support Query & Escalation\nAI attempts to resolve the query directly in the user's language. If resolved, the answer is sent on Telegram. If not, the ticket is logged to Google Sheets, a Slack alert is sent to the support channel, and the customer is told an agent will follow up."
},
"typeVersion": 1
},
{
"id": "fd764ba3-5abf-4dfc-b3f5-86dc4c30ce9c",
"name": "Section \u2013 Error Handling",
"type": "n8n-nodes-base.stickyNote",
"position": [
688,
3232
],
"parameters": {
"color": 7,
"width": 684,
"height": 456,
"content": "## \u26a0\ufe0f Error Handling\nA workflow-level error trigger catches failures across all nodes and posts a structured alert to Slack. Replace `YOUR_SLACK_CHANNEL_ID` with your ops or alerts channel before going live."
},
"typeVersion": 1
},
{
"id": "ed68a5be-f046-4b56-9db5-e2f150c7499b",
"name": "\ud83d\udd11 Credentials & Security",
"type": "n8n-nodes-base.stickyNote",
"position": [
3120,
3296
],
"parameters": {
"color": 3,
"width": 460,
"height": 332,
"content": "## \ud83d\udd11 Credentials Required\n- **Telegram Bot API** \u2014 all Telegram nodes\n- **OpenAI API** \u2014 4 AI nodes\n- **Google Sheets OAuth2** \u2014 Leads, EMI_Simulations, Support_Tickets\n- **Gmail OAuth2** \u2014 hot-lead agent alert\n- **Slack OAuth2** \u2014 escalation + error alerts\n\nNever hardcode sheet IDs or personal credential names in shared templates."
},
"typeVersion": 1
},
{
"id": "a11e70b4-abb9-4d25-8bb7-29f82f54b142",
"name": "Telegram \u2013 Receive Customer Message",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
592,
2816
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"typeVersion": 1.1
},
{
"id": "e00852b4-cfec-4576-b056-dd7172b4a6a8",
"name": "Normalize Input",
"type": "n8n-nodes-base.set",
"position": [
816,
2816
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "assign-chat-id",
"name": "chat_id",
"type": "string",
"value": "={{ $json.message.chat.id }}"
},
{
"id": "assign-user-message",
"name": "user_message",
"type": "string",
"value": "={{ $json.message.text }}"
},
{
"id": "assign-user-name",
"name": "user_name",
"type": "string",
"value": "={{ $json.message.from.first_name }} {{ $json.message.from.last_name }}"
},
{
"id": "assign-username",
"name": "telegram_username",
"type": "string",
"value": "={{ $json.message.from.username }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "3d63dacc-7727-4791-a385-bf2c22b0572f",
"name": "Classify Intent & Language",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1040,
2816
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0
},
"messages": {
"values": [
{
"role": "system",
"content": "You are an intent classifier for a real estate assistant used across India. Detect the language of the user's message and classify their intent into exactly one of: lead_qualification, emi_simulation, support_query. Use lead_qualification when the user is asking about buying/renting property, budgets, or locations. Use emi_simulation when the user mentions loan amount, EMI, mortgage, interest rate, or home loan calculation. Use support_query for anything else (complaints, account issues, general questions). Respond ONLY with valid JSON, no markdown, no extra text, in this exact shape: {\"intent\": \"lead_qualification|emi_simulation|support_query\", \"language\": \"detected language name\", \"language_code\": \"ISO 639-1 code\"}"
},
{
"content": "={{ $json.user_message }}"
}
]
},
"jsonOutput": true
},
"typeVersion": 1.8
},
{
"id": "78c275f5-5269-4cf0-99a2-2c3ddbdef9f7",
"name": "Route by Intent",
"type": "n8n-nodes-base.switch",
"position": [
1424,
2784
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Lead Qualification",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "d0a5c2cf-c1e7-4af5-8427-4cb48cdc742d",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.message.content.intent }}",
"rightValue": "lead_qualification"
}
]
},
"renameOutput": true
},
{
"outputKey": "EMI Simulation",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "7be5ac86-393f-4e5e-9f2d-de9916c4ca29",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.message.content.intent }}",
"rightValue": "emi_simulation"
}
]
},
"renameOutput": true
},
{
"outputKey": "Support Query",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "afb38e7c-1802-4777-93da-93742ed71db5",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.message.content.intent }}",
"rightValue": "support_query"
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3.2
},
{
"id": "ac9e5752-d49a-45d3-ba3b-05139d84704f",
"name": "Extract & Score Lead",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1872,
2224
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0.3
},
"messages": {
"values": [
{
"role": "system",
"content": "You are a real estate lead qualification assistant for the Indian market. From the user's message, extract: budget (numeric, in INR, 0 if unknown), preferred_location (string, empty if unknown), property_type (Apartment/Villa/Plot/Commercial/Unknown), purpose (Buy/Rent/Unknown), urgency (High/Medium/Low), and lead_score (0-100, based on how specific and serious the enquiry is \u2014 vague one-liners score low, specific budget+location+timeline score high). Also write a short reply_text in the user's own language ({{ $json.message.content.language }}) thanking them and asking one relevant follow-up question if info is missing. Respond ONLY with valid JSON in this exact shape: {\"budget\": number, \"preferred_location\": string, \"property_type\": string, \"purpose\": string, \"urgency\": string, \"lead_score\": number, \"reply_text\": string}"
},
{
"content": "={{ $('Normalize Input').item.json.user_message }}"
}
]
},
"jsonOutput": true
},
"typeVersion": 1.8
},
{
"id": "0cd5cd47-5c87-4840-8d44-e1eadd5f68a7",
"name": "Append Lead to Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
2192,
2224
],
"parameters": {
"columns": {
"value": {
"Name": "={{ $('Normalize Input').item.json.user_name }}",
"Chat ID": "={{ $('Normalize Input').item.json.chat_id }}",
"Purpose": "={{ $json.message.content.purpose }}",
"Urgency": "={{ $json.message.content.urgency }}",
"Language": "={{ $('Classify Intent & Language').item.json.message.content.language }}",
"Timestamp": "={{ $now.toISO() }}",
"Lead Score": "={{ $json.message.content.lead_score }}",
"Budget (INR)": "={{ $json.message.content.budget }}",
"Property Type": "={{ $json.message.content.property_type }}",
"Telegram Username": "={{ $('Normalize Input').item.json.telegram_username }}",
"Preferred Location": "={{ $json.message.content.preferred_location }}"
},
"schema": [
{
"id": "Timestamp",
"type": "string",
"display": true,
"required": false,
"displayName": "Timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Telegram Username",
"type": "string",
"display": true,
"required": false,
"displayName": "Telegram Username",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Chat ID",
"type": "string",
"display": true,
"required": false,
"displayName": "Chat ID",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Language",
"type": "string",
"display": true,
"required": false,
"displayName": "Language",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Budget (INR)",
"type": "string",
"display": true,
"required": false,
"displayName": "Budget (INR)",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Preferred Location",
"type": "string",
"display": true,
"required": false,
"displayName": "Preferred Location",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Property Type",
"type": "string",
"display": true,
"required": false,
"displayName": "Property Type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Purpose",
"type": "string",
"display": true,
"required": false,
"displayName": "Purpose",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Urgency",
"type": "string",
"display": true,
"required": false,
"displayName": "Urgency",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Lead Score",
"type": "string",
"display": true,
"required": false,
"displayName": "Lead Score",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Leads"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.5
},
{
"id": "e4ca361b-0ab4-4f04-9ca2-c01e47b156be",
"name": "High Score Lead?",
"type": "n8n-nodes-base.if",
"position": [
2368,
2224
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "number",
"operation": "gte"
},
"leftValue": "={{ $('Extract & Score Lead').item.json.message.content.lead_score }}",
"rightValue": 70
}
]
}
},
"typeVersion": 2.2
},
{
"id": "e367ba57-208f-4d5e-9f1c-488e101014ea",
"name": "Notify Agent \u2013 Hot Lead Email",
"type": "n8n-nodes-base.gmail",
"position": [
2624,
2064
],
"parameters": {
"sendTo": "user@example.com",
"message": "=A new hot lead just came in via Telegram:\n\nName: {{ $('Normalize Input').item.json.user_name }}\nTelegram: @{{ $('Normalize Input').item.json.telegram_username }}\nLanguage: {{ $('Classify Intent & Language').item.json.message.content.language }}\nBudget: \u20b9{{ $('Extract & Score Lead').item.json.message.content.budget }}\nPreferred Location: {{ $('Extract & Score Lead').item.json.message.content.preferred_location }}\nProperty Type: {{ $('Extract & Score Lead').item.json.message.content.property_type }}\nPurpose: {{ $('Extract & Score Lead').item.json.message.content.purpose }}\nUrgency: {{ $('Extract & Score Lead').item.json.message.content.urgency }}\nLead Score: {{ $('Extract & Score Lead').item.json.message.content.lead_score }}/100\n\nOriginal message: {{ $('Normalize Input').item.json.user_message }}\n\nPlease follow up ASAP.",
"options": {},
"subject": "=\ud83d\udd25 Hot Lead: {{ $('Normalize Input').item.json.user_name }} (Score: {{ $('Extract & Score Lead').item.json.message.content.lead_score }})"
},
"typeVersion": 2.1
},
{
"id": "fe2ad2aa-c4f3-4527-8fba-ac4e3b421f82",
"name": "Reply \u2013 Connecting Agent",
"type": "n8n-nodes-base.telegram",
"position": [
2832,
2064
],
"parameters": {
"text": "={{ $('Extract & Score Lead').item.json.message.content.reply_text }}\n\n\ud83d\ude4b One of our property experts will reach out to you shortly!",
"chatId": "={{ $('Normalize Input').item.json.chat_id }}",
"additionalFields": {}
},
"typeVersion": 1.2
},
{
"id": "83664520-8a8c-43db-a26a-1233b1451b2a",
"name": "Reply \u2013 Nurture Lead",
"type": "n8n-nodes-base.telegram",
"position": [
2624,
2384
],
"parameters": {
"text": "={{ $('Extract & Score Lead').item.json.message.content.reply_text }}",
"chatId": "={{ $('Normalize Input').item.json.chat_id }}",
"additionalFields": {}
},
"typeVersion": 1.2
},
{
"id": "7ff8753f-4484-417f-ace5-3cb97b2ecb59",
"name": "Extract Loan Parameters",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1936,
2928
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0
},
"messages": {
"values": [
{
"role": "system",
"content": "You extract home loan / EMI simulation parameters from a user's message, which may be in any Indian language. Extract: loan_amount (numeric, in INR \u2014 if user gives a property price and mentions a down payment, calculate the loan amount, otherwise assume loan_amount = stated amount), interest_rate (annual %, default to 8.5 if not mentioned), tenure_years (default to 20 if not mentioned). Respond ONLY with valid JSON in this exact shape: {\"loan_amount\": number, \"interest_rate\": number, \"tenure_years\": number}"
},
{
"content": "={{ $('Normalize Input').item.json.user_message }}"
}
]
},
"jsonOutput": true
},
"typeVersion": 1.8
},
{
"id": "1f104d3d-3b66-45bd-ac99-b9a8b9db7f27",
"name": "Calculate EMI",
"type": "n8n-nodes-base.code",
"position": [
2224,
2928
],
"parameters": {
"jsCode": "const ai = $json.message.content;\nconst p = parseFloat(ai.loan_amount) || 0;\nconst annualRate = parseFloat(ai.interest_rate) || 8.5;\nconst tenureYears = parseFloat(ai.tenure_years) || 20;\nconst r = (annualRate / 12) / 100;\nconst n = tenureYears * 12;\n\nlet emi = 0;\nif (n > 0 && r > 0) {\n emi = (p * r * Math.pow(1 + r, n)) / (Math.pow(1 + r, n) - 1);\n} else if (n > 0) {\n emi = p / n;\n}\n\nconst totalPayment = emi * n;\nconst totalInterest = totalPayment - p;\n\nreturn [{\n json: {\n loan_amount: p,\n interest_rate: annualRate,\n tenure_years: tenureYears,\n emi: Math.round(emi),\n total_payment: Math.round(totalPayment),\n total_interest: Math.round(totalInterest)\n }\n}];"
},
"typeVersion": 2
},
{
"id": "b156c23d-c0f2-4093-9c5b-db68092aa874",
"name": "Generate EMI Reply",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
2400,
2928
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0.4
},
"messages": {
"values": [
{
"role": "system",
"content": "You write a short, friendly WhatsApp/Telegram-style message in the language: {{ $('Classify Intent & Language').item.json.message.content.language }}, presenting a home loan EMI simulation result to the user. Use the numbers given, format currency in Indian Rupee style (\u20b9), and keep it under 6 lines. End by inviting them to ask about matching properties. Respond ONLY with valid JSON in this exact shape: {\"reply_text\": string}"
},
{
"content": "=Loan Amount: \u20b9{{ $json.loan_amount }}\nInterest Rate: {{ $json.interest_rate }}% per annum\nTenure: {{ $json.tenure_years }} years\nMonthly EMI: \u20b9{{ $json.emi }}\nTotal Interest Payable: \u20b9{{ $json.total_interest }}\nTotal Payment: \u20b9{{ $json.total_payment }}"
}
]
},
"jsonOutput": true
},
"typeVersion": 1.8
},
{
"id": "96bfac49-61d1-44b7-8de5-a1e981303ff1",
"name": "Log EMI Simulation",
"type": "n8n-nodes-base.googleSheets",
"position": [
2736,
2928
],
"parameters": {
"columns": {
"value": {
"Name": "={{ $('Normalize Input').item.json.user_name }}",
"Timestamp": "={{ $now.toISO() }}",
"Loan Amount": "={{ $('Calculate EMI').item.json.loan_amount }}",
"Monthly EMI": "={{ $('Calculate EMI').item.json.emi }}",
"Tenure Years": "={{ $('Calculate EMI').item.json.tenure_years }}",
"Interest Rate": "={{ $('Calculate EMI').item.json.interest_rate }}",
"Total Interest": "={{ $('Calculate EMI').item.json.total_interest }}",
"Telegram Username": "={{ $('Normalize Input').item.json.telegram_username }}"
},
"schema": [
{
"id": "Timestamp",
"type": "string",
"display": true,
"required": false,
"displayName": "Timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Telegram Username",
"type": "string",
"display": true,
"required": false,
"displayName": "Telegram Username",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Loan Amount",
"type": "string",
"display": true,
"required": false,
"displayName": "Loan Amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Interest Rate",
"type": "string",
"display": true,
"required": false,
"displayName": "Interest Rate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Tenure Years",
"type": "string",
"display": true,
"required": false,
"displayName": "Tenure Years",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Monthly EMI",
"type": "string",
"display": true,
"required": false,
"displayName": "Monthly EMI",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Total Interest",
"type": "string",
"display": true,
"required": false,
"displayName": "Total Interest",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "EMI_Simulations"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.5
},
{
"id": "f45d0b6d-7efa-41a4-9abf-7aedddf4bec4",
"name": "Send EMI Breakdown",
"type": "n8n-nodes-base.telegram",
"position": [
2944,
2928
],
"parameters": {
"text": "={{ $json.message.content.reply_text }}",
"chatId": "={{ $('Normalize Input').item.json.chat_id }}",
"additionalFields": {}
},
"typeVersion": 1.2
},
{
"id": "9d3f6b62-5232-48b3-98dc-401869be8f5a",
"name": "Answer Support Query",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1888,
3520
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0.2
},
"messages": {
"values": [
{
"role": "system",
"content": "You are a support assistant for a real estate platform. Try to directly and helpfully answer the user's question (topics like account issues, listing visibility, payment status, general how-it-works questions) in their own language: {{ $('Classify Intent & Language').item.json.message.content.language }}. If you can confidently resolve it without needing account-specific private data, set resolved to true. If the question needs a human (billing disputes, legal/contract issues, account-specific data you don't have), set resolved to false and write a short escalation_summary in English for the agent. Respond ONLY with valid JSON in this exact shape: {\"resolved\": boolean, \"answer_text\": string, \"escalation_summary\": string}"
},
{
"content": "={{ $('Normalize Input').item.json.user_message }}"
}
]
},
"jsonOutput": true
},
"typeVersion": 1.8
},
{
"id": "cef902d3-fcce-4254-99f1-d397380f6973",
"name": "Query Resolved?",
"type": "n8n-nodes-base.if",
"position": [
2224,
3520
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.message.content.resolved }}",
"rightValue": true
}
]
}
},
"typeVersion": 2.2
},
{
"id": "465728a4-29b8-45bf-9ee4-d235a9ad9597",
"name": "Reply With Answer",
"type": "n8n-nodes-base.telegram",
"position": [
2480,
3440
],
"parameters": {
"text": "={{ $json.message.content.answer_text }}",
"chatId": "={{ $('Normalize Input').item.json.chat_id }}",
"additionalFields": {}
},
"typeVersion": 1.2
},
{
"id": "6d4f1c97-3b84-4444-9fb8-6a859de7ae86",
"name": "Log Escalated Ticket",
"type": "n8n-nodes-base.googleSheets",
"position": [
2448,
3632
],
"parameters": {
"columns": {
"value": {
"Name": "={{ $('Normalize Input').item.json.user_name }}",
"Status": "Escalated",
"Timestamp": "={{ $now.toISO() }}",
"Original Message": "={{ $('Normalize Input').item.json.user_message }}",
"Telegram Username": "={{ $('Normalize Input').item.json.telegram_username }}",
"Escalation Summary": "={{ $json.message.content.escalation_summary }}"
},
"schema": [
{
"id": "Timestamp",
"type": "string",
"display": true,
"required": false,
"displayName": "Timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Telegram Username",
"type": "string",
"display": true,
"required": false,
"displayName": "Telegram Username",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Original Message",
"type": "string",
"display": true,
"required": false,
"displayName": "Original Message",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Escalation Summary",
"type": "string",
"display": true,
"required": false,
"displayName": "Escalation Summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Status",
"type": "string",
"display": true,
"required": false,
"displayName": "Status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Support_Tickets"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.5
},
{
"id": "48acd067-68a8-4d35-ac4b-1e8f7d65042a",
"name": "Notify Agent \u2013 Unresolved Ticket",
"type": "n8n-nodes-base.slack",
"position": [
2672,
3632
],
"parameters": {
"text": "=\ud83c\udfab Escalated support ticket\n\nName: {{ $('Normalize Input').item.json.user_name }}\nTelegram: @{{ $('Normalize Input').item.json.telegram_username }}\nLanguage: {{ $('Classify Intent & Language').item.json.message.content.language }}\nMessage: {{ $('Normalize Input').item.json.user_message }}\nSummary: {{ $('Answer Support Query').item.json.message.content.escalation_summary }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "YOUR_SLACK_CHANNEL_ID",
"cachedResultName": "your-support-escalations-channel"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"typeVersion": 2.3
},
{
"id": "52c10a55-45f7-436d-b2b6-746c7a51cd70",
"name": "Reply \u2013 Connecting to Support Agent",
"type": "n8n-nodes-base.telegram",
"position": [
2880,
3632
],
"parameters": {
"text": "={{ $('Answer Support Query').item.json.message.content.answer_text }}\n\n\ud83d\ude4b I'm connecting you with one of our support agents who'll follow up shortly.",
"chatId": "={{ $('Normalize Input').item.json.chat_id }}",
"additionalFields": {}
},
"typeVersion": 1.2
},
{
"id": "7498000c-8e04-472d-8c5b-1b9d61f1e586",
"name": "Reply \u2013 Fallback Clarification",
"type": "n8n-nodes-base.telegram",
"position": [
1904,
3744
],
"parameters": {
"text": "Thanks for reaching out! Could you tell me a bit more \u2014 are you looking to buy/rent a property, calculate a home loan EMI, or do you have a support question? \ud83d\ude42",
"chatId": "={{ $('Normalize Input').item.json.chat_id }}",
"additionalFields": {}
},
"typeVersion": 1.2
},
{
"id": "5005fbb5-6091-4675-a82d-031b8a75cbb8",
"name": "On Workflow Error",
"type": "n8n-nodes-base.errorTrigger",
"position": [
768,
3472
],
"parameters": {},
"typeVersion": 1
},
{
"id": "e523206d-c191-412f-bf87-8f622c3ec613",
"name": "Slack \u2013 Post Workflow Error Alert",
"type": "n8n-nodes-base.slack",
"position": [
1040,
3472
],
"parameters": {
"text": "=\u26a0\ufe0f *RealtyOS Workflow Error*\n\n*Workflow:* {{ $workflow.name }}\n*Failed Node:* {{ $execution.lastNodeExecuted }}\n*Time:* {{ $now.format('MMM D, YYYY \u2013 HH:mm') }}\n*Execution ID:* {{ $execution.id }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "YOUR_SLACK_CHANNEL_ID",
"cachedResultName": "your-alerts-channel"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"typeVersion": 2.3
}
],
"active": false,
"settings": {
"binaryMode": "separate",
"availableInMCP": false,
"executionOrder": "v1"
},
"versionId": "40c42942-aab7-42f3-81f1-4ca77afd6e83",
"nodeGroups": [],
"connections": {
"Calculate EMI": {
"main": [
[
{
"node": "Generate EMI Reply",
"type": "main",
"index": 0
},
{
"node": "Log EMI Simulation",
"type": "main",
"index": 0
}
]
]
},
"Normalize Input": {
"main": [
[
{
"node": "Classify Intent & Language",
"type": "main",
"index": 0
}
]
]
},
"Query Resolved?": {
"main": [
[
{
"node": "Reply With Answer",
"type": "main",
"index": 0
}
],
[
{
"node": "Log Escalated Ticket",
"type": "main",
"index": 0
}
]
]
},
"Route by Intent": {
"main": [
[
{
"node": "Extract & Score Lead",
"type": "main",
"index": 0
}
],
[
{
"node": "Extract Loan Parameters",
"type": "main",
"index": 0
}
],
[
{
"node": "Answer Support Query",
"type": "main",
"index": 0
}
],
[
{
"node": "Reply \u2013 Fallback Clarification",
"type": "main",
"index": 0
}
]
]
},
"High Score Lead?": {
"main": [
[
{
"node": "Notify Agent \u2013 Hot Lead Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Reply \u2013 Nurture Lead",
"type": "main",
"index": 0
}
]
]
},
"On Workflow Error": {
"main": [
[
{
"node": "Slack \u2013 Post Workflow Error Alert",
"type": "main",
"index": 0
}
]
]
},
"Generate EMI Reply": {
"main": [
[
{
"node": "Send EMI Breakdown",
"type": "main",
"index": 0
}
]
]
},
"Answer Support Query": {
"main": [
[
{
"node": "Query Resolved?",
"type": "main",
"index": 0
}
]
]
},
"Extract & Score Lead": {
"main": [
[
{
"node": "Append Lead to Sheets",
"type": "main",
"index": 0
}
]
]
},
"Log Escalated Ticket": {
"main": [
[
{
"node": "Notify Agent \u2013 Unresolved Ticket",
"type": "main",
"index": 0
}
]
]
},
"Append Lead to Sheets": {
"main": [
[
{
"node": "High Score Lead?",
"type": "main",
"index": 0
}
]
]
},
"Extract Loan Parameters": {
"main": [
[
{
"node": "Calculate EMI",
"type": "main",
"index": 0
}
]
]
},
"Classify Intent & Language": {
"main": [
[
{
"node": "Route by Intent",
"type": "main",
"index": 0
}
]
]
},
"Notify Agent \u2013 Hot Lead Email": {
"main": [
[
{
"node": "Reply \u2013 Connecting Agent",
"type": "main",
"index": 0
}
]
]
},
"Notify Agent \u2013 Unresolved Ticket": {
"main": [
[
{
"node": "Reply \u2013 Connecting to Support Agent",
"type": "main",
"index": 0
}
]
]
},
"Telegram \u2013 Receive Customer Message": {
"main": [
[
{
"node": "Normalize Input",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow listens for Telegram bot messages, uses OpenAI (gpt-4o-mini) to detect language and classify intent, then routes requests to either lead qualification, EMI calculation, or support handling with logging to Google Sheets and escalation via Gmail and Slack. Triggers…
Source: https://n8n.io/workflows/17285/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This comprehensive N8N automation template revolutionizes content creation by delivering a complete end-to-end solution for AI-powered blog generation. Transform simple ideas into fully SEO-optimized,
This workflow runs a Telegram concierge for hotel guests, uses OpenAI (gpt-4o-mini) to classify requests, and updates Google Sheets to manage drivers, room extensions, maintenance tickets, and checkou
This workflow handles customer order complaints submitted via Telegram by looking up order details in Google Sheets, using OpenAI to classify message sentiment, and routing each case to auto-approval,
This workflow handles COD order confirmation and abandoned-cart recovery by combining webhooks, Google Sheets logging, OpenAI message generation, and Telegram messaging with inline buttons, plus Slack
This workflow runs a Telegram restaurant ordering flow that uses OpenAI to parse orders and suggest an upsell, sends a Razorpay payment link, confirms paid orders via a Razorpay webhook, logs orders a