LINE Official Account Automation with n8n: A Practical Guide
Route LINE Official Account messages into your CRM, send order updates and reminders, and add AI replies safely with n8n, including PDPA consent and opt-outs.
If your customers in Thailand reach you on LINE, your team probably answers the same questions all day, copies order numbers into a spreadsheet by hand, and loses track of who asked what. LINE official account automation fixes that without turning your account into a cold robot. This guide shows how to connect a LINE Official Account to n8n, build three workflows that pay off quickly, add AI replies safely, and handle consent and opt-outs under PDPA.
What LINE OA does on its own, and where LINE official account automation helps
A LINE Official Account already comes with useful built-in tools: greeting messages for new friends, keyword-based auto-replies, a rich menu, broadcasts, and a chat inbox your staff can work from. For a small shop with a handful of conversations a day, that is often enough.
The built-in tools stop helping when LINE needs to talk to your other systems:
- An inquiry should become a lead or ticket in your CRM or helpdesk, with the customer's history attached.
- An order status change in your shop or ERP should trigger a message to the right customer.
- An appointment tomorrow should trigger a reminder today, with a button to confirm or reschedule.
- A free-text question should get a useful answer, not a keyword match that misses the point.
That is where the Messaging API and a workflow tool like n8n come in. LINE stays the channel your customers already use; n8n does the routing, lookups and updates behind it.
When not to automate
If you get fewer than a few dozen messages a week and they are all different, a person with the LINE OA Manager app is faster and cheaper than any workflow. Automate the repeated, structured parts first: status updates, reminders, routing. Leave sensitive conversations, complaints and negotiations with people.
How the LINE Messaging API works and how to connect it to n8n
Webhooks, replies and pushes
The Messaging API has two directions.
Inbound: webhooks. When a user sends a message, adds your account as a friend, blocks it, or taps a button, LINE sends an HTTP POST to a webhook URL you configure. The payload contains an events array. Each event has a type (for example message, follow, unfollow or postback), a source with the user's ID, a timestamp, and for messages a replyToken.
Outbound: reply and push. You answer in one of two ways:
| Method | When to use | Counts toward your message quota |
|---|---|---|
| Reply message | Directly answering an event, using its replyToken | No |
| Push message | Sending to a user at any time, using their user ID | Yes |
| Multicast or broadcast | Sending the same message to many users | Yes |
A reply token is single use and only valid for a short time after the event, so reply quickly and use push for anything that happens later, such as an order shipping two days from now.
Two details matter for production:
- Signature verification. Every webhook request carries an
x-line-signatureheader. It is an HMAC-SHA256 of the raw request body, keyed with your channel secret and Base64 encoded. If you do not check it, anyone who finds your webhook URL can send fake events into your workflows. - The user ID is not a phone number. LINE gives you an opaque user ID per provider. To connect a LINE user to a CRM contact, you need a linking step, covered below.
The official LINE Messaging API documentation describes every event type and message format.
Setting up the channel
The rough path looks like this. Console screens change, so follow the current LINE documentation for the exact clicks.
- Create or open your LINE Official Account in the LINE Official Account Manager.
- Enable the Messaging API for that account and assign it to a provider. Use one provider for all your LINE channels (including LINE Login, if you add it later) so user IDs stay consistent.
- Note the channel secret and issue a channel access token in the LINE Developers Console. Store both as credentials in n8n, never in a workflow node as plain text.
- Create a webhook workflow in n8n with a Webhook node (POST). Enable the option to receive the raw body, because the signature is calculated over the exact bytes LINE sent.
- Paste the production webhook URL into the channel's webhook settings, turn on "Use webhook", and run the verify check.
- Decide who answers what. In the OA Manager response settings, turn off built-in auto-replies that would collide with your workflow, or keep them for topics your workflow ignores. Two systems answering the same message confuses customers fast.
The skeleton workflow in n8n
Every LINE workflow we build starts with the same front door:
- Webhook node receives the POST.
- Crypto node (HMAC, SHA256, Base64) computes the signature from the raw body and the channel secret.
- IF node compares it with the
x-line-signatureheader. Mismatch: stop and log. - Respond to Webhook node returns HTTP 200 right away, so LINE does not treat a slow workflow as a failed delivery.
- Split Out node turns the
eventsarray into one item per event. - Switch node routes by
type:follow,unfollow,message,postback. - Each branch ends in an HTTP Request node that calls the Messaging API with the channel access token as a Bearer header.
For outbound calls, a plain HTTP Request node is the most predictable option: it works with every endpoint, and you see exactly what goes over the wire.
{
"replyToken": "{{ $json.replyToken }}",
"messages": [
{ "type": "text", "text": "Thanks, we got your message. A team member will reply within business hours." }
]
}
That body goes to the reply endpoint. A push message looks the same, but uses "to": "<userId>" instead of replyToken.
Three workflows that pay off: inquiry routing, order updates, reminders
1. Inquiry routing into your CRM or helpdesk
Goal: every new conversation becomes a contact and a ticket, assigned to the right person.
- On a
messageevent, look up the LINE user ID in your CRM. - If found, add the message to the open ticket or create a new one.
- If not found, call the profile endpoint to get the display name, create a contact with the LINE user ID in a custom field, and ask a short follow-up question.
- Classify the topic (sales, support, billing) with rules first: rich menu buttons that send postbacks are far more reliable than guessing from text.
- Notify the assigned person in Slack, email or the helpdesk, and send the customer a short acknowledgement via reply.
Linking users to customers. Ask once for an email, phone number or order number, verify it against your records, and store the LINE user ID on the contact. If customers also log in on your website, LINE Login under the same provider gives you the same user ID without asking. Our guide on how to connect your CRM to everything with n8n covers the CRM side in more detail.
2. Order and delivery updates
Goal: customers get status updates without asking "where is my order?"
- Trigger on the shop or ERP event (webhook, or a scheduled check for changed orders).
- Look up the customer's LINE user ID. No ID or no consent: fall back to email or SMS.
- Send a push message with the status, the tracking link and a button to contact support.
- Log the message ID and status in the order record.
This is the same pattern we used in an e-commerce automation project that automated order processing and customer notifications, where manual data entry dropped by 80% and order processing went from 15 minutes to under 30 seconds per order.
3. Appointment reminders
Goal: fewer no-shows, with confirmations that flow back into your calendar.
- A Schedule Trigger runs each morning and pulls tomorrow's appointments.
- For each one with a linked LINE user, push a message with two buttons: Confirm and Reschedule. Buttons send postback events with the appointment ID.
- The webhook workflow handles the postback: Confirm updates the calendar entry; Reschedule sends a booking link or creates a task for staff.
Keep reminders short. A customer who feels spammed blocks the account, and you lose the channel for every future update.
Adding AI replies without losing control
AI is useful on LINE where questions are free text and repeated: opening hours, delivery areas, product details, how to return something. It is risky where a wrong answer costs money or trust.
A setup that holds up in production:
- Answer only from your own content. Give the model a short, maintained knowledge base (FAQ, policies, product data) and instruct it to say it does not know otherwise.
- Classify before answering. A first step decides: FAQ, order question, complaint, or something else. Only FAQ goes to the AI answer. Order questions go to a lookup. Complaints go to a person.
- Set a confidence gate. If the model is unsure, or the topic is refunds, legal or health, hand over to a human and tell the customer someone will reply.
- Make handover visible. Tag the conversation in your helpdesk and pause automated replies for that user until staff close the case.
- Answer in the customer's language. Thai and English often arrive on the same account.
- Log every AI answer with the question, the sources used and the output, so you can review and improve.
Our post on human-in-the-loop AI automation with n8n shows approval and handover patterns in depth, and the broader AI-powered customer support guide helps you decide which questions are worth automating at all.
Consent, opt-outs and PDPA basics
This section is general information, not legal advice. Check your setup with a qualified advisor.
Thailand's Personal Data Protection Act (PDPA) applies when you collect and use personal data such as LINE user IDs, names, phone numbers and chat content. A few practical habits keep you on the right side of it:
- Separate transactional from marketing messages. Order updates the customer expects are different from promotions. Track marketing consent as its own field, with the date and how it was given.
- Ask for consent clearly. When a user adds your account (
followevent), send a short welcome with a link to your privacy notice and a button to opt in to news and offers. Store the answer. - Honor blocks and opt-outs. An
unfollowevent means the user blocked your account. Mark the contact, stop all LINE pushes for them, and do not try to reach them through another channel for marketing without a legal basis. - Offer an easy opt-out. A rich menu item or a keyword like "stop" should switch off marketing messages without a phone call.
- Minimize what you store. Keep what the workflow needs. If an AI step processes chats, know where that provider stores data and for how long.
- Restrict access. Channel secrets, access tokens and chat logs belong in protected credentials and systems with access control, not in shared sheets.
Message quotas, costs and monitoring
Quotas. LINE Official Account plans in Thailand differ mainly in how many push, multicast and broadcast messages are included each month, and in whether you can send more than that for an additional fee. Reply messages do not count toward the quota. Plan names and limits change, so check the current plans in the OA Manager before you design a workflow that sends many pushes.
To stay inside it, answer within the event whenever you can, so a reply replaces a push, and combine updates: one message with status and tracking beats three.
Running costs come from the LINE plan, your n8n hosting, and AI usage if you add AI replies. AI costs scale with volume and context length, so a lean knowledge base is cheaper as well as more accurate.
Monitoring. Treat LINE like any other production integration:
- Add an Error Trigger workflow that alerts you when a LINE workflow fails.
- Check the API response of every push and log failures with the user ID and reason.
- Read your quota usage from the Messaging API on a schedule and alert at, for example, 80% of the monthly allowance.
- Deduplicate events by their webhook event ID, because LINE can redeliver an event if your endpoint did not respond in time.
- Watch the block rate after each campaign.
Frequently asked questions
Can I still use LINE Notify for alerts?
No. LINE has ended the LINE Notify service. For alerts to customers or to your own team, use the Messaging API with push messages, or send internal alerts through a channel like email or Slack.
Do I need the Messaging API if I only want auto-replies?
Not for simple keyword replies. The built-in auto-replies in the OA Manager handle that. You need the Messaging API once LINE should read from or write to other systems, or when you want AI answers.
How do I connect a LINE user to an existing customer record?
Ask the customer once for an identifier you can verify, such as an order number or email, then store their LINE user ID on the contact. If customers log in on your site, LINE Login under the same provider can link accounts without the extra question.
Is n8n safe to run this on?
Yes, if it is set up properly: HTTPS, signature checks on every webhook, credentials stored encrypted, regular updates and backups. Self-hosted n8n also keeps chat data in a location you control.
How we can help
LINE is where many customers in Thailand already are, and connecting it to your CRM, shop and calendar removes a lot of copy-paste work from your team. Start with one workflow, usually inquiry routing or order updates, measure it for a month, then add the next.
If you want a second pair of eyes, our AI & Automation service designs, builds and runs n8n workflows like these, with rules-based automation first and AI only where the input is messy. Describe one LINE process in the free workflow check, and we send you concrete improvement ideas and a fixed quote.