Back to Zeroclaw

LINE

docs/book/src/channels/line.md

0.7.45.3 KB
Original Source

LINE

ZeroClaw supports LINE via the Messaging API — receiving messages through an embedded webhook server and replying via the Reply API (with Push API fallback when the reply token has expired).

Prerequisites

  1. A LINE Developers Console account.
  2. A public HTTPS endpoint reachable from LINE's servers (or ngrok for local development).
  3. ZeroClaw built with LINE channel support enabled (the channel-line feature on the zeroclaw-channels crate).

1. Create a LINE Bot

  1. Log in to the LINE Developers Console.
  2. Create a Provider (or use an existing one).
  3. Create a new Messaging API channel under that Provider.
  4. From the channel settings, collect two values:
    • Channel Access Token — Messaging API tab → Issue a long-lived token.
    • Channel Secret — Basic settings tab.

2. Configure ZeroClaw

Configure the LINE channel under [channels.line] with at minimum channel_access_token and channel_secret. See the Config reference for the full field index, defaults, and the dm_policy / group_policy enums (whose user-facing semantics are also covered in §6 below).

Using environment variables instead of config file

If you prefer not to store credentials in the config file, omit the token fields and export them as environment variables instead:

bash
export LINE_CHANNEL_ACCESS_TOKEN="your-channel-access-token"
export LINE_CHANNEL_SECRET="your-channel-secret"

Environment variables take precedence over empty config fields.


3. Expose the Webhook Endpoint

LINE delivers messages by posting to your webhook URL. The embedded server listens on the configured webhook_port.

For local development (ngrok):

bash
ngrok http 8443

Copy the https:// URL ngrok provides (e.g. https://abc123.ngrok.io).

For production: expose port 8443 (or the port you configured) behind an HTTPS reverse proxy (nginx, Caddy, etc.) or deploy directly on a server with a TLS certificate.


4. Register the Webhook in LINE Developers Console

  1. Go to your channel → Messaging API tab → Webhook settings.
  2. Set Webhook URL to https://your-domain.com/line/webhook.
  3. Toggle Use webhook to on.
  4. Click Verify — LINE will send a test request. ZeroClaw must be running for verification to succeed.

5. Start ZeroClaw

bash
./target/release/zeroclaw --config zeroclaw.toml

Or via daemon mode:

bash
zeroclaw daemon

Startup log signal:

LINE: webhook server listening on http://0.0.0.0:8443/line/webhook

6. Access Policies

DM (1:1 chat) — dm_policy

ValueBehaviour
pairing (default)The bot ignores all DMs until the user sends /bind <code>. A pairing code is displayed in the ZeroClaw log at startup.
openThe bot responds to every DM immediately.
allowlistThe bot responds only to LINE user IDs listed in allowed_users.

Pairing workflow:

  1. ZeroClaw prints a pairing code in the log at startup.
  2. The user opens a LINE DM with the bot and sends /bind <code>.
  3. ZeroClaw confirms the pairing; subsequent DMs are accepted.

Group / multi-person chat — group_policy

ValueBehaviour
mention (default)The bot responds only when explicitly @mentioned.
openThe bot responds to every message in the group.
disabledThe bot ignores all group messages entirely.

7. Audio / Voice Message Transcription (optional)

When transcription is enabled (via the global [transcription] config — see Config reference), LINE audio message events are automatically downloaded from the LINE Content API and transcribed before being passed to the model.

The maximum accepted audio size is 25 MB. Larger files are silently skipped with a log warning.


8. Troubleshooting

SymptomLikely causeAction
LINE Verify failsZeroClaw not running, or port not reachableConfirm the process is up and the port is accessible from the internet
Bot does not reply to DMsdm_policy = pairing and user has not run /bindUser must send /bind <code> first, or switch to dm_policy = open
Bot does not reply in groupsgroup_policy = mention and message has no @mention@mention the bot, or switch to group_policy = open
Reply arrives as a push messageReply token expired (~30 s window)Expected fallback behaviour — no action required
Audio messages ignored[transcription] not configuredAdd [transcription] block with enabled = true

Log keywords

SignalLog message
Startup healthyLINE: webhook server listening on http://0.0.0.0:<port>/line/webhook
Signature rejectedLINE: invalid X-Line-Signature
Unauthorized DMLINE: DM from <userId> rejected by policy
Pairing requiredLINE: unpaired user <userId>; ignoring until /bind
Audio ignored (no transcription)LINE: audio message ignored (transcription not configured)
Audio transcription failedLINE: transcription failed for <messageId>:

See also