LINE
LINE Messaging API adapter for Chat SDK. Send text and Flex Message cards, receive media and postback actions, and verify signed webhooks.
Install
pnpm add chat-adapter-line chat @chat-adapter/state-memoryQuick start
The memory state adapter keeps subscriptions and locks in process memory, which suits local development. Use Redis or PostgreSQL in production.
When called with no arguments, createLineAdapter() reads LINE_CHANNEL_ACCESS_TOKEN and LINE_CHANNEL_SECRET from the environment.
Platform setup
- Create a provider and channel in the LINE Developers Console.
- Enable the Messaging API for the channel.
- Copy the channel access token and channel secret.
- Set the webhook URL to a public HTTPS endpoint, such as
https://your-domain.com/api/webhooks/line. - Subscribe to message and postback events.
Configuration
Prop
Type
Environment variables
| Variable | Required | Description |
|---|---|---|
LINE_CHANNEL_ACCESS_TOKEN | Yes | LINE channel access token, unless you pass channelAccessToken. |
LINE_CHANNEL_SECRET | Yes | LINE channel secret, unless you pass channelSecret. |
Webhooks
LINE sends each webhook with an x-line-signature header. The adapter computes an HMAC-SHA256 digest with the channel secret and compares it with the header before parsing the body.
Messages and cards
Text and Markdown output are converted to plain text. Chat SDK cards become LINE Flex Messages: the card title and text become the bubble body, and buttons become postback actions in the footer. Button clicks dispatch to Chat SDK action handlers.
Attachments
The adapter receives image, video, audio, and file messages as attachments. It doesn't upload outbound files. Posting a message with files logs a warning and sends any text or card content.
Streaming
Streaming is buffered. The adapter sends a text message after it collects more than 500 characters, then sends the remaining text after the stream ends. It sends at most five messages per stream.
Thread IDs
sourceType is user, group, or room. sourceId is the LINE user, group, or room ID.
Feature support
Messaging
| Feature | Supported |
|---|---|
| Post message | |
| Message replies | |
| Edit message | |
| Delete message | |
| File uploads | Inbound only |
| Streaming | Buffered chunks |
| Scheduled messages |
Rich content
| Feature | Supported |
|---|---|
| Card format | LINE Flex Messages |
| Buttons | Card postbacks |
| Link buttons | |
| Select menus | |
| Tables | |
| Charts | |
| Fields | |
| Images in cards | |
| Modals |
Conversations
| Feature | Supported |
|---|---|
| Slash commands | |
| Mentions | |
| Add reactions | |
| Remove reactions | |
| Typing indicator | DMs only |
| Mark as read | |
| Message edit events | |
| Message delete events | |
| DMs | |
| Ephemeral messages | |
| User lookup | DM profiles |
| Parent subject | |
| Native client | |
| Custom API endpoint |
Message history
| Feature | Supported |
|---|---|
| Fetch messages | |
| Fetch single message | |
| Fetch thread info | Users and groups |
| Fetch channel messages | |
| List threads | |
| Fetch channel info | Group name |
| Post channel message |