Build a Telegram Customer-Support Bot for Your Store With n8n

AgentRoost · May 26, 2026 · 7 min read · View as Markdown
AgentRoost — Telegram Bots

Running a small online store means answering the same questions on repeat: "Where is my order?", "Do you ship to X?", "What sizes do you carry?". A Telegram bot that handles the tier-one queue frees you for the edge cases that actually need a human — and n8n is the cleanest way to wire it up because you own the logic, the data flows, and the conversation history.

This guide walks you through the complete build: a Telegram bot that reads your FAQ, pulls live order status when asked, and uses an AI node to compose natural replies — all running 24/7 inside your own n8n instance.

What You Are Building

  • A Telegram bot that stays alive permanently (no sleeping serverless function)
  • A router that detects intent: FAQ lookup vs. order status vs. hand-off to human
  • An AI node that drafts the final reply using your product data as context
  • An order-status branch that queries your store's API (Shopify, WooCommerce, or any REST endpoint)

No separate OpenAI subscription. No hardcoded API keys. The AI credits are part of the package.

Step 1 — Create Your Telegram Bot

Open Telegram and start a chat with @BotFather. Send /newbot, follow the prompts, and copy the token it returns. You will paste this into n8n shortly.

Set a description and a profile picture while you are there — customers will see it before they send the first message.

Step 2 — Add the Telegram Trigger Node

Add a Telegram Trigger node. In its credentials, paste your bot token. Set the event to Message. This node opens a webhook connection to Telegram and fires the workflow every time a user sends a message.

Tip: n8n offers both polling and webhook modes for Telegram. On a persistent, always-on instance the webhook mode is more efficient — no wasted polling cycles. Your public subdomain on AgentRoost gives Telegram a reachable HTTPS URL out of the box.

Under Trigger On, pick Message and enable text messages at minimum. You can add photo later if you want customers to send product photos.

Step 3 — Classify Intent With a Switch Node

Not every message is the same. Add a Switch node after the trigger and define three outputs:

Output Condition
order_lookup message text matches regex /order\s*#?\d+/i or contains "where is my order"
faq everything else that isn't an escalation keyword
human message contains "agent", "human", "complaint", or a CAPS-LOCK pattern

You can also replace the Switch with a single AI/LLM node that classifies intent — more on that in the next step.

Step 4 — FAQ Branch

Create a static FAQ as a Code node (or a Set node with a large JSON field) containing your product questions and answers:

[
  { "q": "What are your shipping times?", "a": "We ship within 2 business days. EU delivery takes 3–5 days." },
  { "q": "Do you offer returns?", "a": "Yes, 30-day returns on unused items. Email us with your order number." },
  { "q": "What sizes do you carry?", "a": "XS through 3XL. See the size chart on each product page." }
]

Feed this JSON into an AI/LLM node. Set the system prompt to something like:

You are a helpful support assistant for [Your Store Name].
Answer the customer's question using ONLY the FAQ data provided.
If the answer is not in the FAQ, reply: "I'll connect you with a human agent."
Keep your answer under 3 sentences and do not make up policies.

Pass the incoming message as the user prompt. The node outputs a drafted reply string.

Step 5 — Order Status Branch

Add an HTTP Request node on the order_lookup path. Extract the order number from the message using a Code node or a regex expression in a Set node:

// In a Code node
const match = $('Telegram Trigger').item.json.message.text.match(/\d+/);
return [{ json: { orderId: match ? match[0] : null } }];

Then configure the HTTP Request node:

  • Method: GET
  • URL: https://your-store.com/api/orders/{{ $json.orderId }} (replace with your store's endpoint)
  • Authentication: Header Auth → add your store API key in n8n's credential vault

The response likely includes status, trackingNumber, and estimatedDelivery. Pass these fields into a Set node to build a clean message:

Your order #{{ $json.orderId }} is {{ $json.status }}.
Tracking: {{ $json.trackingNumber }}
Estimated delivery: {{ $json.estimatedDelivery }}

Step 6 — Human Hand-Off Branch

For the human output, send a Telegram node message back to the customer ("Connecting you with our team — expect a reply within a few hours.") and simultaneously use an HTTP Request or Email node to ping your support inbox or Slack channel with the full conversation text. A simple webhook to your helpdesk (Freshdesk, Linear, Notion, whatever you use) works fine here.

Step 7 — Send the Reply

All three branches converge at a Telegram node configured to Send Message. Set:

  • Chat ID: {{ $('Telegram Trigger').item.json.message.chat.id }}
  • Text: the output from whichever branch ran

Enable Parse Mode: Markdown if you want to bold the order status or add links.

Pitfalls to Avoid

Don't let the AI hallucinate policies. Ground it strictly in the FAQ JSON. A clear instruction like "do not make up return windows, shipping costs, or product specs" goes a long way.

Handle missing order IDs gracefully. If the regex returns null, branch to a friendly "Could you share your order number? It looks like #12345." reply rather than sending a broken URL to your store API.

Rate-limit repeat messages. A single angry customer can trigger your workflow dozens of times a minute. Add an IF node that checks a simple in-memory store (or a Postgres node) to throttle the same chat ID to one response per 10 seconds.

Keep secrets in credentials, not in Set nodes. n8n's credential vault encrypts API keys at rest. Never paste them as plain text in a workflow node — if you export the workflow JSON they will be exposed.

How to Run This on AgentRoost

You need an n8n instance that is always on and reachable by Telegram's webhook servers. Running n8n on your laptop or a sleeping container breaks the Telegram connection every time it goes idle.

On AgentRoost you get your own n8n instance — not a shared platform, not a service where someone else manages your workflows. Your private n8n editor opens at https://<your-id>.agentroost.app, and it stays live 24/7 on dedicated hardware. The Telegram Trigger's webhook URL is public HTTPS the moment you deploy.

The bigger unlock: the AI/LLM node already has credits loaded. You do not set up an OpenAI account, you do not paste an API key, and you do not get surprised by an AI bill at the end of the month. The credits are included in your AgentRoost subscription — all-in from $19.99/mo with a 14-day money-back guarantee.

To get started:

  1. Sign up at AgentRoost — email, Google, Microsoft, or Discord
  2. Pick the n8n framework, give your instance a name
  3. Your n8n editor opens in about 2 minutes
  4. Import the workflow described above (or build it node by node)
  5. Paste your Telegram bot token into the credential vault — done

Compare plans →

What to Build Next

Once the core support flow is working:

  • Product search: add a vector-search node or a simple full-text search against your product catalog so customers can ask "do you have blue sneakers in size 10?"
  • Proactive shipping alerts: a separate Schedule Trigger workflow that queries fulfillment status daily and messages customers before they ask
  • Multi-language replies: pass the detected language from the incoming message to the AI node's system prompt and reply in the customer's own language

All of it runs in the same n8n instance, no extra infrastructure.

Frequently asked questions

Do I need an OpenAI API key to use the AI node in n8n on AgentRoost?

No. AgentRoost includes AI/LLM credits in every subscription plan. The AI nodes in your n8n instance are pre-wired to those credits — you do not need to create an OpenAI account or paste any API key. You can also switch between hundreds of available models from your workspace settings at any time.

Will my Telegram bot go offline if I close the n8n editor?

No. Your n8n instance on AgentRoost runs 24/7 on dedicated hardware — the editor is just a browser UI. The workflow stays active whether your browser is open or not. Telegram's webhook connection persists independently of your editing session.

Can I export my n8n workflows and take them elsewhere?

Yes. n8n's native export (JSON) is fully portable. Your workflows, credentials references, and execution history belong to you. If you ever want to move to a self-hosted server, export from the editor and import on the new instance.

What happens if my store API returns an error or an order is not found?

Add an IF node after the HTTP Request node that checks for a non-200 status code or a null response body, then route those cases to a friendly fallback message like "I couldn't find that order — please double-check the number or contact us at [email protected]."

Can I cancel my AgentRoost subscription if the bot doesn't meet my needs?

Yes. Plans are monthly with no lock-in and a 14-day money-back guarantee. You can cancel from your account dashboard at any time and export your n8n workflows before leaving.