LINE and Telegram bots
LINE and Telegram via n8n
TL;DR — the 30-second summarytldr
This chapter plugs your "storefront" into the customers who already live in chat — LINE and Telegram — with one identical pattern for both: the platform sends a webhook to n8n on the NAS → the workflow calls LiteLLM (model thai-chat-rt) → it replies, and the user gets an answer within ~5–30 seconds
When to usewhen to use
Do this once the core system is ready (chapters 3–4) and you have bot accounts:
- LINE: create a Messaging API channel at console.line.biz (the free plan is enough for answering chats) — you get a channel secret + access token
- Telegram: talk to @BotFather, create a bot, receive a token
- Both need a public webhook URL — use the tunnel/domain name from chapter 2
How-tohow to
The same pipeline for both platforms:
LINE / Telegram platform
-> webhook -> n8n on the NAS (workflow)
1. verify the signature (LINE) or token (Telegram)
2. load the user's conversation state
3. call LiteLLM /v1/chat/completions model=thai-chat-rt
(think off, num_predict 1024, timeout 51 s)
4. format the reply (trim length, convert links, MarkdownV2 for Telegram)
5. reply through the reply APIAll secrets (secret/token) live only in the n8n credential store — never embed them in workflow JSON (a scanner checks weekly)
The UX budget we hold ourselves to: 30 seconds — anything past that counts as a failure no matter how good the answer is (in the 50-case evaluation, 2 cases hit this ceiling — those structured cases were sent to a fallback instead)
If anything gets stuck → chapter 9
Config exampleconfig example
The part you "must" get right is the model route on the LiteLLM side (from chapter 4):
- model_name: thai-chat-rt
litellm_params:
model: ollama_chat/qwen38-chat
extra_body: { "think": false } # the most important line in this chapter
num_predict: 1024 # a ceiling sized for chat
timeout: 51Both bots share one route + one key each (BOM_KEY_LINE / BOM_KEY_TELEGRAM from chapter 4)
Pro tip — field-tested advicepro tip
FAQfaq
Q: A hundred people asking at once — can it cope? — yes; the model answers at ~30 tok/s and n8n manages the queue, but if the business grows to thousands of messages per minute, add the extra safety margin from chapter 9
Q: Are images/voice in chat supported? — voice-to-text (STT) works through Whisper on the i9; images use a vision model according to what the route allows
For other questions see the FAQ
See alsosee also
- Chapter 4 · Virtual keys — the bots' two keys
- Chapter 6 · The Thai recipe — the reasoning behind think:false
- Chapter 9 · Monitoring — probes watch the bots every 5 minutes
Figuresfigures
A sample conversation (reconstructed from real traffic, customer data masked) — you can see the reply comes back in natural Thai: direct answers, no Chinese characters mixed in:
The real conversation was re-summarized to protect customer privacy — the structure of the reply is unchanged
No real platform-side screenshots of the chat room are attached in this edition, because that would mean digging into the bot owner's accounts/sessions (our "never touch the real thing just to take a photo" policy) — the n8n workflow editor is likewise reachable only through internal SSO; to see the real thing, catch the video when it is ready (below)
Videovideo
Real screen recording for this lesson · click play to hear the summary · not investment advice
▶ Watch the manual video: https://youtu.be/O4hM39cgDCY