Prerequisites
- A LINE account
- Access to LINE Developers Console
- A publicly accessible HTTPS endpoint for webhooks (or use ngrok for testing)
Creating a LINE Official Account
-
Create a LINE Developers Account
- Go to https://developers.line.biz/
- Log in with your LINE account
- Accept the terms and conditions
-
Create a Provider
- Click “Create” on the Providers page
- Enter a provider name (e.g., “My Company”)
-
Create a Messaging API Channel
- Click “Create Channel”
- Select “Messaging API”
- Fill in the required information:
- Channel name: Your bot’s name
- Channel description: Brief description
- Category: Select appropriate category
- Subcategory: Select subcategory
- Upload channel icon (optional)
- Click “Create”
-
Get Channel Access Token
- Go to your channel’s “Messaging API” tab
- Under “Channel access token”, click “Issue”
- Save this token - starts with a long string
-
Get Channel Secret
- In the “Basic settings” tab
- Find “Channel secret”
- Save this secret
-
Configure Webhook
- In “Messaging API” tab
- Set “Webhook URL” to your server endpoint:
- Enable “Use webhook”
- Disable “Auto-reply messages” (important!)
- Disable “Greeting messages” (optional)
Configuration
Add the LINE channel to yourconfig.yaml:
Configuration Options
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | Yes | Enable LINE channel |
channel_secret | string | Yes | Channel secret for signature verification |
channel_access_token | string | Yes | Channel access token for API |
webhook_host | string | No | Host to bind webhook server (default: 0.0.0.0) |
webhook_port | int | No | Port for webhook server (default: 8080) |
webhook_path | string | No | Webhook endpoint path (default: /webhook/line) |
allow_from | array | No | Allowed LINE user IDs |
User ID Format
LINE uses 33-character user IDs likeU1234567890abcdef1234567890abcdef.
Finding User IDs:
- Have the user message your bot
- Check Weaver logs:
Webhook Setup
For Production (Public Server)
- Ensure HTTPS: LINE requires HTTPS for webhooks
-
Configure reverse proxy (nginx example):
-
Set webhook URL in LINE Console:
For Development (ngrok)
- Install ngrok: https://ngrok.com/
- Start Weaver (listens on port 8080 by default)
-
Start ngrok:
-
Copy HTTPS URL from ngrok output:
-
Set in LINE Console:
- Verify webhook in LINE Console (should show success)
Supported Features
Message Types
- Text Messages - Full support with quote replies
- Images - Downloaded as
image.jpg - Audio - Downloaded as
audio.m4a - Video - Downloaded as
video.mp4 - Files - Metadata only (no content download)
- Stickers - Detected as
[sticker]
Bot Behavior
1:1 Chats:- Bot responds to all messages
- No mention required
- Bot only responds when @mentioned
- Mention detection uses display name or user ID
- Mention is stripped from message before processing
Reply Features
- Reply API: Used first (free, 25-second validity)
- Push API: Fallback if reply token expires
- Quote Replies: Original message quoted in response
- Loading Animation: 60-second loading indicator shown
Message Sending
LINE channel uses a two-tier sending strategy:-
Reply API (Free)
- Valid for ~25 seconds after receiving message
- Cached and used automatically if available
- No additional cost
-
Push API (Paid)
- Used when reply token expired or unavailable
- Requires messaging plan for high volumes
- First 500 messages/month free (varies by region)
Quote Replies
When configured, bot responses quote the original message:Mention Detection
In group chats, the bot detects mentions by:- Mention Metadata: LINE’s mention object (primary)
- Display Name: Fallback text-based detection using
@BotName - User ID Match: Matches bot’s user ID from mention data
@WeaverBot mention is stripped before processing.
Signature Verification
All webhook requests are verified using HMAC-SHA256:- LINE signs requests with your channel secret
- Weaver verifies the
X-Line-Signatureheader - Invalid signatures are rejected (403 Forbidden)
Error Handling
Common Issues
Invalid Signature- Verify
channel_secretis correct - Ensure webhook request is from LINE servers
- Check webhook URL is publicly accessible
- Verify HTTPS certificate is valid
- Ensure firewall allows inbound connections
- Test with:
curl -X POST https://your-server.com/webhook/line
- Non-fatal warning
- Bot still works but may not detect mentions properly
- Verify channel access token is valid
- Check channel access token
- Verify token has not expired
- Ensure channel is not deleted/suspended
Security Considerations
- Signature Verification: Always enabled, validates all webhooks
- Token Security: Keep channel secret and access token secure
- HTTPS Required: LINE mandates HTTPS for production webhooks
- Allowlist: Use
allow_fromto restrict bot access - IP Whitelisting: Consider restricting to LINE’s webhook IPs
Metadata Captured
Each LINE message includes:Example Configurations
Production Setup
Development with ngrok
Logging
Monitor LINE activity:Cost Considerations
- Reply API: Free (use within 25 seconds of receiving message)
- Push API:
- Free tier: First 500 messages/month (Japan)
- Paid plans available for higher volumes
- Check LINE Official Account pricing
Best Practices
- Respond Quickly: Use Reply API (free) by responding within 25 seconds
- Disable Auto-Reply: Turn off LINE’s auto-reply to avoid duplicate responses
- Add Rich Menu: Configure rich menu in LINE Console for user guidance
- Monitor Costs: Track Push API usage if on paid plan
- Test Webhooks: Use “Verify” button in LINE Console
- Handle Groups Carefully: Only respond to mentions to avoid spam
Next Steps
- Configure Agents to respond on LINE
- Set up Quote Replies for better context
- Enable Multimodal for image understanding