Skip to main content

LINE

KhunQuant connects to LINE via the LINE Messaging API. The LINEChannel adapter receives webhook events from LINE's servers and delivers responses through the LINE reply API. Because LINE pushes events to your server, a publicly accessible HTTPS endpoint is required.

Capabilities

  • Text message send/receive
  • Quoted reply (responses automatically reference the original message)
  • Allow-listing by LINE user ID
  • Group chat support (bot responds only when @mentioned by default)

You can find your LINE user ID at LINE Developers → Your Provider → Your Channel → Basic settings tab.

LINE user ID location

Configuration

Add to ~/.khunquant/config.json:

{
"channels": {
"line": {
"enabled": true,
"channel_secret": "LINE_CHANNEL_SECRET",
"channel_access_token": "LINE_CHANNEL_ACCESS_TOKEN",
"webhook_path": "/webhook/line",
"allow_from": ["ABCDEFGHIJKLMNOP123456"]
}
}
}

Store secrets in ~/.khunquant/.security.yml:

channels:
line:
channel_secret: "abc123..."
channel_access_token: "eyJhbGci..."
FieldTypeDescription
enabledboolEnable the LINE channel
channel_secretSecureStringChannel secret from LINE Developers console
channel_access_tokenSecureStringLong-lived channel access token
webhook_pathstringPath the gateway listens on (default: /webhook/line)
allow_from[]stringAllowlist of LINE user IDs (empty allows all)

Setup Steps

  1. Go to LINE Developers and sign in.

  2. Click the Create button to create a new Provider.

    Create Provider

  3. Click Create a Messaging API channel.

    Create Messaging API channel

  4. Click Create a LINE Official Account for your KhunQuant bot and fill in the form until you submit.

    Create LINE Official Account

  5. You will see your new channel page like this.

    Channel page

  6. Copy the Channel secret from the Basic settings tab and the Channel access token (long-lived) from the Messaging API tab.

  7. Add both credentials to KhunQuant.

    Recommended: Use the Web UI

    Open KhunQuant's channel settings in your browser:

    http://localhost:18800/channels/line

    Paste your Channel Secret and Channel Access Token into the form and click Save. KhunQuant automatically encrypts the values — you never need to touch any config files.

    Why not edit the file directly?

    If your .security.yml already uses encrypted fields (enc:// prefix), pasting a plain token directly into the file will cause an authentication error at startup. The Web UI handles encryption automatically and avoids this problem.

    Alternative: Manual file edit (advanced users only)

    Open ~/.khunquant/.security.yml:

    channels:
    line:
    channel_secret: "abc123..."
    channel_access_token: "eyJhbGci..."
  8. Set the webhook URL in your channel's Messaging API tab to point to your KhunQuant gateway (e.g. https://your-domain/webhook/line) and enable Use webhook.

    Webhook URL field

    Enable webhook toggle

  9. Start KhunQuant.

Local development with ngrok

The KhunQuant gateway listens on port 18790 by default. Expose it publicly with:

ngrok http 18790

Copy the HTTPS URL printed by ngrok (e.g. https://abc123.ngrok.io) and use it as your webhook base URL in the LINE Developers console (https://abc123.ngrok.io/webhook/line).

HTTPS requirement

LINE only delivers events to HTTPS endpoints with a valid TLS certificate. A tunnel like ngrok or a reverse proxy (Caddy, nginx) is the simplest way to satisfy this during local development.