Telegram + Gmail: faster ecommerce support replies
Your support inbox isn’t “busy.” It’s chaotic. Messages come in from everywhere, order lookups take too long, and customers get different answers depending on who replies.
Support managers feel it when SLAs slip. A store owner feels it when refunds spike. And marketers running promos feel it when every campaign triggers a mini support storm. This Telegram Gmail support automation cuts response time down to minutes and keeps replies consistent.
You’ll set up an AI-powered workflow in n8n that routes questions, pulls order info, recommends products, and escalates real issues through Gmail when needed.
How This Automation Works
Here’s the complete workflow you’ll be setting up:
n8n Workflow Template: Telegram + Gmail: faster ecommerce support replies
flowchart LR
subgraph sg0["AI Agent Flow"]
direction LR
n0@{ icon: "mdi:robot", form: "rounded", label: "AI Agent", pos: "b", h: 48 }
n1@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model", pos: "b", h: 48 }
n2["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Code"]
n3@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Switch", pos: "b", h: 48 }
n4@{ icon: "mdi:robot", form: "rounded", label: "Order Queries", pos: "b", h: 48 }
n5@{ icon: "mdi:swap-vertical", form: "rounded", label: "getOrderStatus", pos: "b", h: 48 }
n6@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model1", pos: "b", h: 48 }
n7@{ icon: "mdi:memory", form: "rounded", label: "Simple Memory", pos: "b", h: 48 }
n8@{ icon: "mdi:memory", form: "rounded", label: "Simple Memory1", pos: "b", h: 48 }
n9@{ icon: "mdi:robot", form: "rounded", label: "AI Agent1", pos: "b", h: 48 }
n10@{ icon: "mdi:brain", form: "rounded", label: "handle support tickets", pos: "b", h: 48 }
n11@{ icon: "mdi:memory", form: "rounded", label: "Simple Memory2", pos: "b", h: 48 }
n12@{ icon: "mdi:wrench", form: "rounded", label: "Code Tool", pos: "b", h: 48 }
n13@{ icon: "mdi:message-outline", form: "rounded", label: "Send", pos: "b", h: 48 }
n14@{ icon: "mdi:swap-vertical", form: "rounded", label: "createSupportTicket", pos: "b", h: 48 }
n15@{ icon: "mdi:swap-vertical", form: "rounded", label: "getTicketStatus", pos: "b", h: 48 }
n16@{ icon: "mdi:robot", form: "rounded", label: "Recommendations", pos: "b", h: 48 }
n17@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model2", pos: "b", h: 48 }
n18@{ icon: "mdi:memory", form: "rounded", label: "Simple Memory3", pos: "b", h: 48 }
n19@{ icon: "mdi:swap-vertical", form: "rounded", label: "getCategoryRecommendations", pos: "b", h: 48 }
n20@{ icon: "mdi:swap-vertical", form: "rounded", label: "getProductRecommendations", pos: "b", h: 48 }
n21["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/webhook.dark.svg' width='40' height='40' /></div><br/>Webhook"]
n22["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/webhook.dark.svg' width='40' height='40' /></div><br/>Respond to Webhook"]
n23["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/webhook.dark.svg' width='40' height='40' /></div><br/>Respond to Webhook1"]
n24["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/webhook.dark.svg' width='40' height='40' /></div><br/>Respond to Webhook2"]
n25["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/webhook.dark.svg' width='40' height='40' /></div><br/>Respond to Webhook3"]
n2 --> n3
n13 -.-> n9
n3 --> n4
n3 --> n16
n3 --> n9
n3 --> n25
n21 --> n0
n0 --> n2
n9 --> n24
n12 -.-> n9
n4 --> n22
n7 -.-> n4
n8 -.-> n0
n11 -.-> n9
n18 -.-> n16
n5 -.-> n4
n16 --> n23
n15 -.-> n9
n1 -.-> n0
n6 -.-> n4
n17 -.-> n16
n14 -.-> n9
n10 -.-> n9
n20 -.-> n16
n19 -.-> n16
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0,n4,n9,n16 ai
class n1,n6,n10,n17 aiModel
class n12 ai
class n7,n8,n11,n18 ai
class n3 decision
class n21,n22,n23,n24,n25 api
class n2 code
classDef customIcon fill:none,stroke:none
class n2,n21,n22,n23,n24,n25 customIcon
Why This Matters: Slow Replies Create Expensive Tickets
Ecommerce support looks simple until you’re living in it. One customer asks for order tracking, another wants a size recommendation, and a third is angry because a package didn’t arrive. The “quick” work is never quick because you bounce between admin panels, search order IDs, then rewrite the same reassurance message for the hundredth time. And when a message gets handled late (or inconsistently), it turns into follow-ups, chargebacks, and public complaints you now have to clean up.
It adds up fast. Here’s where it typically breaks down in real teams.
- Order status questions force constant context switching between chat, store admin, and your database.
- Reps copy-paste replies, so tone and policies drift from person to person over time.
- Escalations get lost because “someone will email them” is not a process.
- When promos hit, the same three questions arrive all day, and your team still answers them manually.
What You’ll Build: An AI Support Router That Replies, Looks Up Orders, and Escalates
This workflow starts with an incoming webhook from your site, store, help widget, or any system that can send a request. n8n passes the message to an AI intent classifier that decides what the customer is actually asking: general support, order status, product recommendations, or a ticket-worthy issue. Based on that intent, the workflow routes the conversation to the right AI agent, which can remember recent context so follow-ups don’t feel like starting over. If the customer needs order tracking, the workflow retrieves order details from your Supabase database and responds immediately. If they need recommendations, it pulls product or category data and generates a helpful suggestion. And if it’s a support ticket, it generates a ticket ID, stores the record, then sends an escalation email through Gmail so your team can step in with all context included.
The flow is simple to reason about. A webhook triggers the workflow, AI classifies intent, then a switch routes the request to the correct “lane.” Each lane ends by responding right away, which keeps your customer experience fast even when backend steps (like email) are happening.
What You’re Building
| What Gets Automated | What You’ll Achieve |
|---|---|
|
|
Expected Results
Say you get about 30 support messages a day. A typical manual loop is 5 minutes to read, check an order system, paste a reply, and log a note, which is roughly 2–3 hours daily. With this workflow, the customer gets an instant response via webhook (seconds), and your team only steps in on real ticket cases; even then, Gmail sends the escalation automatically with the ticket ID and context. Most teams get back about 2 hours a day and, honestly, the mental load drop is just as valuable.
Before You Start
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Telegram for internal alerts and support routing
- Gmail to send escalations and ticket emails
- OpenAI API key (get it from your OpenAI dashboard)
- Supabase to store and fetch orders/tickets
- Google Sheets for lightweight logging or reporting
Skill level: Intermediate. You’ll connect accounts, add API keys, and map a few fields from your webhook payload.
Want someone to build this for you? Talk to an automation expert (free 15-minute consultation).
Step by Step
A webhook receives the customer message. Your site, store, or help widget sends the question (and whatever identifiers you have, like email or order number) into n8n’s Incoming Webhook Trigger.
AI classifies intent and keeps context. An intent classifier agent uses an OpenAI chat model, plus session memory, to decide what lane the message belongs in and to remember recent back-and-forth.
Routing sends the request to the right assistant. A switch node splits into four paths: general reply, order status, product recommendations, or support ticket handling. Each path uses its own AI agent and memory so conversations stay coherent.
Data lookups and escalations happen behind the scenes. The order and recommendation paths query Supabase tools for order details and product/category info. The ticket path generates a ticket ID, stores the ticket record, and dispatches a Gmail message for your team to handle.
You can easily modify the intent categories to match your store (for example, “returns,” “shipping delay,” or “wholesale”) based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Webhook Trigger
Set up the inbound webhook that receives support messages and starts the routing flow.
- Add Incoming Webhook Trigger and set HTTP Method to
POST. - Set Path to
4cdaa2e9-be46-4f60-83f6-8d7bd4a6ad5d. - Set Response Mode to
responseNodeso downstream nodes (Return Order Response, Return Recommendation Response, Return Ticket Response, Return General Reply) return the webhook response. - Keep Flowpast Branding as a documentation-only sticky note (optional).
Tip: Send a POST body containing message and session_id fields to align with the AI memory configuration later in the workflow.
Step 2: Connect the Intent Classifier and Session Memory
Configure the initial AI classification layer that determines where each request should be routed.
- In Intent Classifier Agent, set Text to
=Here is the query of user {{ $json.body.message }}. - Connect Primary Chat Model as the language model for Intent Classifier Agent. Credential Required: Connect your openAiApi credentials.
- Connect Session Memory Core as memory for Intent Classifier Agent and set Session Key to
={{ $json.body.session_id }}with Context Window Length7.
⚠️ Common Pitfall: Do not add credentials to Session Memory Core—memory nodes inherit access via the parent agent. Ensure credentials are set on Primary Chat Model instead.
Step 3: Parse Intent and Route Requests
Parse the classifier output and route to the correct assistant based on intent.
- In Parse Intent Payload, keep the JavaScript Code as provided to parse the agent’s JSON output into
category. - In Route by Intent, confirm each rule uses
={{ $json.category.intent }}and matches: - Set the four rule values to
order_status,product_recommendation,support_ticket, andgeneral. - Ensure Route by Intent connects to Order Status Assistant, Product Suggestion Agent, Support Ticket Agent, and Return General Reply based on the matched intent.
Tip: This switch routes to only one path at a time based on intent, so confirm the classifier returns valid JSON and a supported intent string.
Step 4: Configure the Order Status Path
Set up the order tracking assistant to retrieve order status and respond to the user.
- In Order Status Assistant, set Text to
=The query of the user is this .{{ $('Incoming Webhook Trigger').item.json.body.message }}. - Connect Order Chat Model as the language model. Credential Required: Connect your openAiApi credentials.
- Connect Order Memory Buffer as memory with Session Key
={{ $('Incoming Webhook Trigger').item.json.body.session_id }}and Context Window Length7. - Configure Retrieve Order Status with Table
ordersand Operationget, with filter value={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}. Credential Required: Connect your supabaseApi credentials. - In Return Order Response, keep Response Body as
={ "response": "{{ $json.output.replace(/[\n\r\t]+/g, ' ').replace(/\s{2,}/g, ' ').trim() }}" }.
⚠️ Common Pitfall: Tools like Retrieve Order Status are called by the agent, so credentials must be valid and the Supabase table must exist with matching field names.
Step 5: Configure the Product Recommendation Path
Set up the recommendation assistant to query product data based on user intent.
- In Product Suggestion Agent, set Text to
=The query of the user is this . {{ $('Incoming Webhook Trigger').item.json.body.message }}. - Connect Recommendation Chat Model as the language model. Credential Required: Connect your openAiApi credentials.
- Connect Recommendation Memory with Session Key
={{ $('Incoming Webhook Trigger').item.json.body.session_id }}and Context Window Length7. - Configure Product Recommendation Lookup with Table
products, Operationget, and filter value={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}. Credential Required: Connect your supabaseApi credentials. - Configure Category Recommendation Lookup with Table
products, Operationget, and filter value={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions1_Value', ``, 'string') }}. Credential Required: Connect your supabaseApi credentials. - In Return Recommendation Response, keep Response Body set to
={ "response":"{{ JSON.stringify($json.output) }}" }.
Tip: There are multiple Supabase tools in this workflow. Confirm all Supabase tools point to the correct project and tables to avoid partial failures.
Step 6: Configure the Support Ticket Path
Enable ticket creation and status lookup, including email notifications to your support team.
- In Support Ticket Agent, set Text to
=The message/qiery of the user {{ $('Incoming Webhook Trigger').item.json.body.message }}. - Connect Support Chat Model as the language model. Credential Required: Connect your openAiApi credentials.
- Connect Support Memory Buffer with Session Key
={{ $('Incoming Webhook Trigger').item.json.body.session_id }}and Context Window Length7. - Ensure Generate Ticket ID Tool is connected as an AI tool (no credentials required) and its code is unchanged.
- Configure Create Ticket Record with Table
support_ticketsand field values using the provided={{ /*n8n-auto-generated-fromAI-override*/ $fromAI(...) }}expressions. Credential Required: Connect your supabaseApi credentials. - Configure Retrieve Ticket Status with Table
support_ticketsand filter value={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}. Credential Required: Connect your supabaseApi credentials. - In Dispatch Support Email, set Send To to
[YOUR_EMAIL]and keep Subject and Message as expressions. Credential Required: Connect your gmailOAuth2 credentials. - In Return Ticket Response, keep Response Body as
={ "response": "{{ $json.output.replace(/[\n\r\t]+/g, ' ').replace(/\s{2,}/g, ' ').trim() }}" }.
⚠️ Common Pitfall: The tools Create Ticket Record, Retrieve Ticket Status, and Dispatch Support Email are called by Support Ticket Agent. Validate those credentials and fields before testing to prevent silent failures.
Step 7: Test and Activate Your Workflow
Validate each intent path and confirm the correct webhook response is returned.
- Use the Incoming Webhook Trigger test URL and send sample payloads with
messageandsession_id. - Verify the execution path: Incoming Webhook Trigger → Intent Classifier Agent → Parse Intent Payload → Route by Intent → the correct assistant node.
- Confirm successful responses from Return Order Response, Return Recommendation Response, Return Ticket Response, or Return General Reply.
- Once tests pass, toggle the workflow to Active for production use.
Troubleshooting Tips
- Gmail credentials can expire or need specific permissions. If things break, check the Gmail connection in n8n’s Credentials list first.
- If you’re seeing empty order results, it’s usually a mismatch between your webhook payload and the Supabase lookup fields. Double-check the order ID/email mapping in the “Retrieve Order Status” tool step.
- Default prompts in the OpenAI agent nodes are generic. Add your brand voice and policy rules early (returns, refunds, shipping windows) or you’ll be editing outputs forever.
Quick Answers
About 45 minutes if Supabase and Gmail are already connected.
No. You’ll mainly connect accounts and map a few fields from your webhook payload.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in OpenAI API costs (often a few cents per conversation) and whatever Supabase plan you’re on.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and you should. Most changes happen in “Route by Intent” (the categories), plus the Supabase tool steps used for lookups like “Retrieve Order Status” and “Create Ticket Record.” Common customizations include adding a “returns/refunds” lane, changing what data is pulled into the order response, and pushing a copy of ticket data into Google Sheets for reporting.
Usually it’s expired OAuth access or the wrong Google account connected. Reconnect Gmail in n8n Credentials, then rerun a single test execution to confirm the “Dispatch Support Email” step can send. If you’re using a shared inbox, confirm that mailbox permissions are enabled on the Google Workspace side. Also check sending limits if you suddenly started escalating lots of tickets in a short window.
If you self-host, there’s no execution cap; it mostly depends on your server and API rate limits.
Often, yes, because this workflow isn’t just “send message from A to B.” You’re classifying intent, branching into multiple paths, using memory for follow-ups, and doing database lookups before replying, which is where simpler tools can get awkward or expensive. n8n also gives you a self-hosting route, so you’re not paying more just because you’re busy. That said, if you only need a basic escalation (like “new form submission → send email”), Zapier or Make can be quicker to set up. Talk to an automation expert if you want help picking the simplest option that still works.
Once this is running, routine questions stop stealing attention. Your customers get answers fast, and your team gets a calmer queue they can actually manage.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.