Skip to content

PunGrumpy/chat-adapter-line

Chat SDK LINE Adapter

LINE Messaging API adapter for Chat SDK — send and receive messages from your bot.

Installation

npm install chat-adapter-line

Usage

import { Chat } from "chat";
import { createLineAdapter } from "chat-adapter-line";

const bot = new Chat({
  userName: "mybot",
  adapters: {
    line: createLineAdapter(),
  },
});

bot.onNewMention(async (thread) => {
  await thread.subscribe();
  await thread.post("Hello! I'm listening to this thread.");
});

bot.onSubscribedMessage(async (thread, message) => {
  await thread.post(`You said: ${message.text}`);
});

the factory reads credentials from the environment variables by default.

Environment Variable Required Description
LINE_CHANNEL_ACCESS_TOKEN Yes The access token for the LINE channel.
LINE_CHANNEL_SECRET Yes The secret for the LINE channel.

or pass them as options to the factory:

const adapter = createLineAdapter({
  channelAccessToken: "eyJhbG...",
  channelSecret: "abc123...",
});

License

MIT

Benchmarking

This package includes targeted benchmarks for hot paths:

  • Markdown normalization (toPlainText)
  • Thread ID encode/decode
  • Webhook signature + parse path

Run benchmarks:

vp run benchmark

Export JSON results:

vp run benchmark:json

About

Chat SDK adapter for Line

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Contributors