# Host a LINE bot. Webhook in one sentence.

> Host a LINE bot without a server or ngrok: one sentence in Claude Code, Codex or Cursor deploys it to Agent Lab with a fixed HTTPS webhook URL. Free to try.

Web page: https://agentlab.cresclab.com/en/deploy/line-bot  
繁體中文 (Markdown): https://agentlab.cresclab.com/deploy/line-bot.md

LINE bot hosting · Agent Lab Deploy

No ngrok: say one sentence to your AI tool and Agent Lab builds your bot with a fixed HTTPS webhook URL.

[Host a LINE bot free](https://app.agentlab.cresclab.com/?lang=en&intent=deploy) [Jump to the Dockerfile](https://agentlab.cresclab.com/en/deploy/line-bot#recipe)

A Claude Code conversation: the user asks the agent to deploy a LINE bot; the agent creates the app, points to where the channel secrets go in the console, and returns the webhook URL once the build passes.

Why here

## Most LINE bot problems are the webhook URL.

LINE needs public HTTPS with a valid certificate; Agent Lab has it on deploy.

### A fixed HTTPS URL

Publicly trusted, unchanged on restart, so Verify passes once.

### Channel secrets out of code

Project secrets read from the environment, never committed to GitHub.

### A database when you need one

PostgreSQL in the same workspace for users and chat history.

Choosing

## Laptop + ngrok vs a VPS vs Agent Lab

Three ways to host a LINE bot compared

| What matters to you | Agent Lab Deploy | Laptop + ngrok | Your own VPS |
| --- | --- | --- | --- |
| Webhook URL | Fixed HTTPS | Changes on restart (free plan) | Buy a domain, add a certificate |
| Laptop closed | Keeps running | Bot stops | Keeps running |
| Cost | **Free to try**; always-on from Pro at US$29/month | Free (URL changes) | A few dollars a month plus time |
| Secrets | On the platform | In a local .env | You manage them |
| Setup | One sentence to an AI tool | Runs, but not for production | SSH, Docker, Nginx, Let's Encrypt |

How

## Connect → one sentence → secrets → paste the webhook

1. ### Connect Agent Lab
   One MCP line in your AI tool, one browser sign-in.
2. ### Say one sentence
   The agent creates and builds the app, and names missing secrets.
3. ### Enter the channel secrets
   Console › Project › Settings › Secrets: channel secret and access token.
4. ### Paste the webhook URL
   Paste https://<name>--<org>.hosting.agentlab.run/webhook into LINE Developers and press Verify.

Copy and go

## The Dockerfile and the sentence

Node.js with the official @line/bot-sdk: listen on $PORT, answer /webhook with 200 first.

Dockerfile

### Dockerfile

```
FROM node:22-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev          # @line/bot-sdk, express
COPY . .
USER node
EXPOSE 8080
CMD ["node", "server.js"]

// server.js
// const line = require("@line/bot-sdk");
// const express = require("express");
// const config = { channelSecret: process.env.LINE_CHANNEL_SECRET };
// const client = new line.messagingApi.MessagingApiClient({
//   channelAccessToken: process.env.LINE_CHANNEL_ACCESS_TOKEN });
// const app = express();
// app.post("/webhook", line.middleware(config), async (req, res) => {
//   res.sendStatus(200);   // answer LINE first, then work
//   for (const e of req.body.events) if (e.type === "message")
//     await client.replyMessage({ replyToken: e.replyToken,
//       messages: [{ type: "text", text: e.message.text }] });
// });
// app.listen(process.env.PORT);
```

- `LINE_CHANNEL_SECRET` Basic settings; proves requests are from LINE
- `LINE_CHANNEL_ACCESS_TOKEN` Messaging API; to reply and push
- `PORT` the port the platform gives

PROMPT

### Say this to your AI tool

```
Read https://app.agentlab.cresclab.com/agent/deploy.md and deploy this LINE bot to Agent Lab with the Dockerfile at agentlab.cresclab.com/en/deploy/line-bot: listen on $PORT, webhook at /webhook. Tell me where in the console to enter LINE_CHANNEL_SECRET and LINE_CHANNEL_ACCESS_TOKEN rather than asking for them in the chat. Give me the webhook URL when the build passes.
```

FAQ

## Before you host a LINE bot

**Where should I host a LINE bot? Is there free hosting?**

The Free plan runs one size-S LINE bot at no charge, sleeping after 15 idle minutes; to stay on and miss nothing, Pro is US$29 a month before tax.

**Do I need ngrok?**

No. ngrok is for laptop testing: it stops with the laptop and the free URL changes. On Agent Lab the bot has a fixed HTTPS URL.

**How do I set the LINE webhook URL?**

Paste https://<name>--<org>.hosting.agentlab.run/webhook into LINE Developers › Messaging API › Webhook settings, turn on Use webhook and press Verify.

**Where do the channel secret and access token go?**

Console › Project › Settings › Secrets; the code reads LINE_CHANNEL_SECRET and LINE_CHANNEL_ACCESS_TOKEN from the environment, never from source or chat.

**Can I connect ChatGPT or Claude for an AI assistant?**

Yes. On each message, call OpenAI, Anthropic or Gemini and send a reply message; the API key is another project secret. [See the complete LINE AI Agent workflow](https://agentlab.cresclab.com/en/channels/line)
