Build a LINE chatbot or webhook with AI and host it on BrewInTH

Build a LINE chatbot with AI that answers from real data, saves bookings and sends a morning summary, on BrewInTH's HTTPS. Prompt and common pitfalls included.
Every day customers message your shop on LINE with the same questions: "What time do you open?", "What's on the menu?", "Can I book a table?" You answer by hand all day. LINE Official Account's built-in auto-replies help a little, but they cannot read your shop's real data or write anything into your own system.
This article shows how to build your own LINE chatbot with AI that answers from real data, takes table bookings into a database and sends the owner a summary every morning — hosted on BrewInTH, which gives it HTTPS automatically. The same idea works for any other webhook, such as payment notifications or answers from another service's form.
In short
💬 A LINE chatbot is a small web app with an HTTPS "webhook address" that LINE sends messages to
💬 BrewInTH gives every project an HTTPS address the moment it is created; no SSL setup
💬 The channel secret and access token go in the App settings tab, never in the code
💬 Check theX-Line-Signatureon every request and answer LINE quickly
💬 On the Free package an app sleeps after 3 days without a visitor; a bot that must always answer belongs on a paid package set to "Never"
What a webhook is, and why a chatbot needs one
A webhook is "an address another service calls" when something happens. When someone messages your LINE Official Account, LINE's servers send that message to the webhook address you configured. Your app reads it, works out a reply and calls LINE's API to answer.

What a webhook needs is an HTTPS address that is always up. Your own computer is a poor fit: it has to stay on, and it needs an SSL certificate. That is the part BrewInTH handles: every project gets its own address such as https://yourname.host.brewinth.net with HTTPS from the start, and apps can call outside APIs on any port (except port 25, used for sending mail directly).
What you need
- A LINE Official Account with the Messaging API enabled, set up through LINE Official Account Manager and the LINE Developers Console
- The channel secret and a channel access token from the channel's Messaging API page
- A BrewInTH account and an AI coding agent on your computer (Claude Code, Codex, Cursor or Windsurf)
LINE's screens change from time to time; if a menu does not match what is written here, follow LINE's current Messaging API documentation.
Step by step
Step 1: Create the project on BrewInTH
Create a new project. For the technology choose Let the platform decide (recommended), for the database PostgreSQL (for bookings and history), give it an easy free site name such as cafe-bot, then create the link and token for your AI.
Step 2: Put LINE's values in App settings
Open the project's App settings tab and add:
LINE_CHANNEL_SECRET= the channel secretLINE_CHANNEL_ACCESS_TOKEN= the channel access tokenOWNER_LINE_USER_ID= the shop owner's user ID (for summaries; can be added later)
These are the bot's keys: anyone who has them can send messages as your shop. Never paste them into the code or into a chat. New values apply when the app restarts, so have the AI release again after changing them.
Step 3: Ask the AI to write the bot
Build a LINE chatbot for the café "Baan Dok Mai" in Node.js and deploy it to BrewInTH following the guide at the link.
- POST /webhook receives events from the LINE Messaging API
- Verify X-Line-Signature with HMAC-SHA256 using LINE_CHANNEL_SECRET,
computed on the raw body before parsing JSON; answer 401 if it does not match
- Answer HTTP 200 to LINE immediately, even when events is empty (the Verify button)
- "menu", "hours" and "location" are answered from the shop_info table
- "book" asks for the date, time and party size one step at a time, then saves to bookings;
remember each user's step by userId in the database
- Anything else: reply that staff will get back to them, and save it in an inbox table
- Reply with the reply API using LINE_CHANNEL_ACCESS_TOKEN
- GET /health answers 200; set healthPath to /health
- Keep data in the project's database; read secrets only from the environment
Step 4: Set the webhook on LINE's side
- In the LINE Developers Console open the channel and go to the Messaging API section
- Set the Webhook URL to
https://yourname.host.brewinth.net/webhook - Press Verify; it must succeed
- Turn on Use webhook
- In LINE Official Account Manager turn off the auto-reply messages, or customers get two answers

Step 5: Test and read the logs
Add the LINE OA as a friend on your phone, then try "menu", "book" and something random. If the bot stays silent, open the project's Logs tab and press Fetch logs: did a request from LINE arrive, did the signature pass, did LINE's API return an error? Copy the log to your AI and let it fix the problem.
Step 6: Send the owner a summary every morning
Use the project's Schedules tab (or ask the AI to set it up) to run a command at 8 a.m. that summarises today's bookings and sends them to OWNER_LINE_USER_ID with the push API. Push messages count against your LINE OA plan's quota; check LINE's terms before messaging many people.
Four things that silence a bot most often

- The signature fails. It must be computed on the raw body exactly as LINE sent it. If the framework parses JSON first and re-serialises it, the signature will not match.
- LINE is answered too slowly. Answer 200 first and do the heavy work (such as calling another AI to phrase a reply) afterwards. A reply token works once and expires quickly.
- The app is asleep. On the Free package an app sleeps after 3 days without a single visitor. The first message after that meets an app that is waking up (a 503 for a few tens of seconds), and LINE may not send it again. For a bot that must always be ready, use a paid package and set Autosleep in App settings to Never (always on).
- No health page. A bot without a home page fails the readiness check at
/. AddGET /healthanswering 200 and set it as the healthPath.
Does this work for other webhooks?
Yes, the principle is the same everywhere: a payment provider telling you someone paid, a form service sending answers, or GitHub announcing new code.
- Webhook address = the project's HTTPS address + a path such as
/webhooks/payment - The signing secret goes in App settings
- Verify the signature every time; never trust data just because it arrived at a secret address
- Answer 2xx quickly, and make repeats harmless (store the event ID and skip it if seen before)
FAQ
Can I still use LINE Notify for alerts?
LINE Notify has been shut down. To send alerts into LINE, use the Messaging API as in this article (a push message to the owner or to a group the bot is in).
Do I need my own domain?
No. The BrewInTH HTTPS address works as a webhook straight away. If you connect your shop's domain later, remember to change the Webhook URL on LINE too.
Can I use the Free package?
For trying and building, fully. But the app sleeps after 3 days without a visitor. A bot that customers message every day rarely sleeps; if it must be ready 100% of the time, use a paid package (from Starter at ฿99/month) and set it never to sleep.
Can the bot answer with an AI like ChatGPT?
Yes. Keep the AI provider's API key in App settings and call it after answering LINE with 200. Limit how often each user can ask, so the AI bill stays under control.
Where are customers' messages stored?
In your own project's database. They are personal data: keep only what you need and say so in your shop's privacy policy (this article is not legal advice).
Summary
Your own LINE chatbot is a small web app with an HTTPS webhook address: create a project on BrewInTH, put the channel secret and token in App settings, have your AI write a bot that verifies signatures and answers fast, set the Webhook URL on LINE, then test while reading the logs. If the bot must always be ready, use a paid package and set it never to sleep.
Start your first project for free →
