Introduction
LINE is the dominant instant messaging app in regions such as Japan, Thailand, and Taiwan. By connecting OpenClaw to LINE, you can create an intelligent chatbot that automatically replies to friend messages or provides AI services in group chats. This article guides you through the entire integration process, starting from the LINE Developers console.
Prerequisites
- OpenClaw is installed and running
- You have a LINE account
- The OpenClaw service is accessible via a public HTTPS URL (LINE Webhook requires HTTPS)
Step 1: Create a LINE Messaging API Channel
1.1 Register a LINE Developers Account
- Visit LINE Developers
- Log in with your LINE account
- If this is your first time, agree to the developer terms and create a Provider
1.2 Create a Provider
A Provider is the top-level organizational unit for managing channels:
- In the LINE Developers Console, click Create a new provider
- Enter a Provider name (e.g., "My OpenClaw Bot")
- Click Create
1.3 Create a Messaging API Channel
- On the Provider page, click Create a Messaging API channel
- Fill in the following information:
| Field | Description | Example |
|---|---|---|
| Channel type | Select Messaging API | Messaging API |
| Channel name | Bot display name | AI Assistant |
| Channel description | Bot description | Smart assistant powered by OpenClaw |
| Category | Select a category | Tools/Utilities |
| Subcategory | Select a subcategory | Chatbot |
| Email address | Contact email | [email protected] |
- Agree to the terms and click Create
1.4 Obtain Required Credentials
After creation, you need to note down two key pieces of information:
Channel Secret: Found on the Basic settings tab.
Channel Access Token:
- Go to the Messaging API tab
- Scroll to the Channel access token section at the bottom
- Click the Issue button to generate a long-lived token
- Copy and save it securely
Channel Secret: abc123def456ghi789jkl012
Channel Access Token: eyJhbGciOiJIUzI1NiJ9.xxxxx.xxxxx (a very long string)
Step 2: Configure the Webhook
2.1 Set the Webhook URL
On the Messaging API tab:
- Find the Webhook settings section
- Click the Edit button
- Enter your Webhook URL:
https://your-domain.com/webhook/line
- Click Update
- Toggle the Use webhook switch on
2.2 Verify the Webhook
Click the Verify button to test the Webhook connection. If OpenClaw is already configured and running, it should display Success.
2.3 Disable Auto-Reply
On the Messaging API tab:
- Find the LINE Official Account features section
- Click the Edit link next to Auto-reply messages
- This opens the LINE Official Account Manager
- Disable Auto-reply messages (otherwise they will conflict with OpenClaw's replies)
- Optionally disable Greeting messages as well (or keep LINE's default greeting)
Step 3: Configure OpenClaw
3.1 Via Configuration File
Edit ~/.config/openclaw/openclaw.json5:
{
channels: {
line: {
enabled: true,
// Channel Secret (from Basic settings)
channelSecret: "abc123def456ghi789jkl012",
// Channel Access Token (generated from Messaging API)
channelAccessToken: "eyJhbGciOiJIUzI1NiJ9.xxxxx.xxxxx",
// Webhook path (must match the LINE console setting)
webhookPath: "/webhook/line",
// Message handling configuration
message: {
// Reply mode: "reply" uses Reply API (free), "push" uses Push API (may incur charges)
replyMode: "reply",
// Whether to support group messages
groupEnabled: true,
// Trigger method in groups
groupTrigger: "mention", // "mention" | "keyword" | "all"
// Group trigger keywords (effective when groupTrigger is "keyword")
groupKeywords: ["@AI", "/ask"]
},
// Reply format
reply: {
// Auto-split long messages
maxLength: 5000,
// Whether to use Flex Message format (more visually appealing)
useFlexMessage: false,
// Loading animation before sending a message
loadingAnimation: true
}
}
}
}
3.2 Via Environment Variables
export LINE_CHANNEL_SECRET="abc123def456ghi789jkl012"
export LINE_CHANNEL_ACCESS_TOKEN="eyJhbGciOiJIUzI1NiJ9.xxxxx.xxxxx"
3.3 Restart and Verify
openclaw restart
# View connection logs
openclaw logs -f --component channel:line
Successful logs:
[INFO] [channel:line] LINE Messaging API channel started
[INFO] [channel:line] Webhook path: /webhook/line
[INFO] [channel:line] Bot name: AI Assistant
[INFO] [channel:line] Waiting for incoming messages...
Reply API vs. Push API
LINE has two APIs for sending messages, and understanding the difference is important:
Reply API
- Trigger: Can only be used after receiving a user message
- Time limit: Reply Token is valid for approximately 30 seconds
- Cost: Completely free
- Limitation: Each event can only be replied to once
Push API
- Trigger: Can proactively send messages to users
- Time limit: None
- Cost: Free plan includes 200 messages/month; additional messages require payment
- Limitation: Depends on the subscription plan
{
channels: {
line: {
message: {
// Recommended: use reply mode to save costs
replyMode: "reply",
// Enable push as a fallback for delayed replies (e.g., time-consuming tasks)
fallbackToPush: true
}
}
}
}
Message Quota
| Plan | Push API Messages/Month | Cost |
|---|---|---|
| Free | 200 | Free |
| Light | 5,000 | ~800 TWD/month |
| Standard | 25,000 | ~4,000 TWD/month |
| Pro | Custom | Contact LINE |
Reply API messages do not count toward the quota, so using Reply mode is recommended whenever possible.
Rich Menu Configuration
A Rich Menu is a customizable menu at the bottom of a LINE Bot conversation, providing quick-action shortcuts.
Creating a Rich Menu
Create one in the LINE Official Account Manager:
- Go to Chat > Rich menu
- Click Create
- Design the menu layout; common options:
┌─────────┬─────────┬─────────┐
│ │ │ │
│ Ask │Translate│Summarize│
│ │ │ │
├─────────┼─────────┼─────────┤
│ │ │ │
│ Reset │ Model │ Help │
│ │ │ │
└─────────┴─────────┴─────────┘
- Set each area's action type to Text and enter the corresponding trigger command
Creating a Rich Menu via API
You can also define a Rich Menu in the OpenClaw configuration:
{
channels: {
line: {
richMenu: {
enabled: true,
areas: [
{ label: "Ask", action: "/ask" },
{ label: "Translate", action: "/translate" },
{ label: "Summarize", action: "/summarize" },
{ label: "Reset Chat", action: "/reset" },
{ label: "Switch Model", action: "/model" },
{ label: "Help", action: "/help" }
]
}
}
}
}
Group Usage
Adding the Bot to a Group
- Open the group in LINE
- Go to group settings > Invite
- Search for and add your Bot
Group Behavior Configuration
{
channels: {
line: {
group: {
// Welcome message when joining a group
welcomeMessage: "Hi everyone, I'm an AI assistant! @mention me or start with /ask to ask a question.",
// Clean up data when removed from a group
cleanOnLeave: true,
// Separate context for each group
separateContext: true
}
}
}
}
HTTPS Requirement
LINE Webhook strictly requires HTTPS. If you haven't configured HTTPS yet, you can use one of the following methods:
Option 1: Nginx Reverse Proxy + Let's Encrypt
# Install certbot
sudo apt install certbot python3-certbot-nginx
# Obtain a certificate
sudo certbot --nginx -d your-domain.com
Option 2: ngrok Tunnel (for development and testing)
# Install ngrok
npm install -g ngrok
# Create a tunnel
ngrok http 18789
Enter the ngrok-generated HTTPS address as the LINE Webhook URL.
Option 3: Cloudflare Tunnel
cloudflared tunnel --url http://localhost:18789
Troubleshooting
Webhook Verification Failed
# Confirm OpenClaw is running
openclaw logs --level error
# Confirm the Webhook path is correct
curl -X POST https://your-domain.com/webhook/line -d '{}' -H "Content-Type: application/json"
# Check if the SSL certificate is valid
openssl s_client -connect your-domain.com:443
Bot Not Replying to Messages
# Check if the Channel Access Token is valid
openclaw logs --component channel:line --level debug
# Common causes:
# 1. Token expired — re-issue a new Token
# 2. Auto-reply not disabled — LINE's auto-reply consumes the Reply Token
# 3. Reply Token timeout — AI model response took too long (>30 seconds)
Reply Token Timeout
If the AI model takes more than 30 seconds to respond, the Reply Token will expire. Solutions:
{
channels: {
line: {
message: {
replyMode: "reply",
fallbackToPush: true, // Fall back to Push API if Reply fails
// Or send a "processing" reply first
thinkingMessage: "Thinking, please wait..."
}
}
}
}
Summary
Key steps for LINE integration:
- Create a Messaging API channel in LINE Developers
- Obtain the Channel Secret and Channel Access Token
- Configure an HTTPS Webhook URL
- Enter the credentials in the OpenClaw configuration file
- Disable LINE's auto-reply feature
- Restart the service and test
It is recommended to use the Reply API whenever possible to save costs, and to enhance the user experience with a Rich Menu.