Skip to main content
Agent skill

Chat Sdk

Use for multi-platform bots built with chat SDK: webhooks, mentions, slash commands, cards, modals and streaming.

All install options
Quick install · Personal (~/.claude/skills)Project / Cursor / Desktop →
mkdir -p ~/.claude/skills/chat-sdk && curl -fsSL 'https://raw.githubusercontent.com/lobehub/lobehub/canary/.agents/skills/chat-sdk/SKILL.md' -o ~/.claude/skills/chat-sdk/SKILL.md

Get the complete skill folder, including its scripts and reference files.

When to use this skill

Use Chat Sdk when an AI agent needs a reusable SKILL.md workflow for this job: Use for multi-platform bots built with chat SDK: webhooks, mentions, slash commands, cards, modals and streaming.

When not to use it

Skip Chat Sdk when the task is outside the coding category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.

How to install

Where will you use it?

Install scope
One-line install (Claude Code)
mkdir -p ~/.claude/skills/chat-sdk && curl -fsSL 'https://raw.githubusercontent.com/lobehub/lobehub/canary/.agents/skills/chat-sdk/SKILL.md' -o ~/.claude/skills/chat-sdk/SKILL.md
  1. Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/chat-sdk/SKILL.md. For a shared project, commit the folder at .claude/skills/chat-sdk/ instead.
  2. Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
  3. For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.

Full install guide for Claude, Cursor, and Codex →

Try a starter prompt

After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.

Starter prompt
Use the Chat Sdk skill for this task: Use Chat Sdk when this documented workflow matches the task. Confirm any required inputs or files before making changes.

What supports this recommendation?

68/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.

Documentation
71/100
Practical detail
68/100
Source evidence
63/100
Source signals
70/100
Model compatibility evidence
  • claudeinferred

    The skill text mentions Claude or a closely associated term. This is keyword-derived compatibility; no hands-on model test is recorded.

  • chatgptuntested

    No model-specific signal or recorded compatibility test was found.

  • geminiuntested

    No model-specific signal or recorded compatibility test was found.

  • copilotuntested

    No model-specific signal or recorded compatibility test was found.

  • llamauntested

    No model-specific signal or recorded compatibility test was found.

  • perplexityuntested

    No model-specific signal or recorded compatibility test was found.

  • mistraluntested

    No model-specific signal or recorded compatibility test was found.

  • grokuntested

    No model-specific signal or recorded compatibility test was found.

Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.

What this skill does

# Chat SDK

Unified TypeScript SDK for building chat bots across Slack, Teams, Google Chat, Discord, GitHub, and Linear. Write bot logic once, deploy everywhere.

## Critical: Read the bundled docs

The `chat` package ships with full documentation in `node_modules/chat/docs/` and TypeScript source types. **Always read these before writing code:**

``` node_modules/chat/docs/ # Full documentation (MDX files) node_modules/chat/dist/ # Built types (.d.ts files) ```

Key docs to read based on task:

- `docs/getting-started.mdx` — setup guides - `docs/usage.mdx` — event handlers, threads, messages, channels - `docs/streaming.mdx` — AI streaming with AI SDK - `docs/cards.mdx` — JSX interactive cards - `docs/actions.mdx` — button/dropdown handlers - `docs/modals.mdx` — form dialogs (Slack only) - `docs/adapters.mdx`, `docs/platform-adapters.mdx` — adapter overview and platform-specific setup - `docs/state-adapters.mdx` — state adapter config (Redis, ioredis, memory)

Also read the TypeScript types from `node_modules/chat/dist/` to understand the full API surface.

## Quick start

```typescript import { Chat } from 'chat'; import { createSlackAdapter } from '@chat-adapter/slack'; import { createRedisState } from '@chat-adapter/state-redis';

const bot = new Chat({ userName: 'mybot', adapters: { slack: createSlackAdapter({ botToken: process.env.SLACK_BOT_TOKEN!, signingSecret: process.env.SLACK_SIGNING_SECRET!, }), }, state: createRedisState({ url: process.env.REDIS_URL! }), });

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}`); }); ```

## Core concepts

- **Chat** — main entry point, coordinates adapters and routes events - **Adapters** — platform-specific (Slack, Teams, GChat, Discord, GitHub, Linear) - **State** — pluggable persistence (Redis for prod, memory for dev) - **Thread** — conversation thread with `post()`, `subscribe()`, `startTyping()` - **Message** — normalized format with `text`, `formatted` (mdast AST), `raw` - **Channel** — container for threads, supports listing and posting

## Event handlers

| Handler | Trigger | | -------------------------- | ------------------------------------------------- | | `onNewMention` | Bot @-mentioned in unsubscribed thread | | `onSubscribedMessage` | Any message in subscribed thread | | `onNewMessage(regex)` | Messages matching pattern in unsubscribed threads | | `onSlashCommand("/cmd")` | Slash command invocations | | `onReaction(emojis)` | Emoji reactions added/removed | | `onAction(actionId)` | Button clicks and dropdown selections | | `onAssistantThreadStarted` | Slack Assistants API thread opened | | `onAppHomeOpened` | Slack App Home tab opened |

## Streaming

Pass any `AsyncIterable<string>` to `thread.post()`. Works with AI SDK's `textStream`:

```typescript import { ToolLoopAgent } from 'ai'; const agent = new ToolLoopAgent({ model: 'anthropic/claude-sonnet-5' });

bot.onNewMention(async (thread, message) => { const result = await agent.stream({ prompt: message.text }); await thread.post(result.textStream); }); ```

## Cards (JSX)

Set `jsxImportSource: "chat"` in tsconfig. Components: `Card`, `CardText`, `Button`, `Actions`, `Fields`, `Field`, `Select`, `SelectOption`, `Image`, `Divider`, `LinkButton`, `Section`, `RadioSelect`.

```tsx await thread.post( <Card title="Order #1234"> <CardText>Your order has been received!</CardText> <Actions> <Button id="approve" style="primary"> Approve </Button> <Button id="reject" style="danger"> Reject </Button> </Actions> </Card>, ); ```

## Packages

`chat` and the `@chat-adapter/*` packages are an external SDK this repo consumes (pinned via semver range in `package.json`), not something built or versioned here — there's no Changesets/release flow to document for them.

| Package | Purpose | | --------------------------------- | --------------------------------------------------------------------------------------- | | `chat` | Core SDK | | `@chat-adapter/discord` | Discord | | `@chat-adapter/slack` | Slack | | `@chat-adapter/telegram` | Telegram | | `@chat-adapter/state-ioredis` | ioredis state | | `@lobechat/chat-adapter-feishu` | Lark/Feishu — built in-repo (`packages/chat-adapter-feishu`), not from `@chat-adapter/` | | `@lobechat/chat-adapter-imessage` | iMessage via BlueBubbles — built in-repo | | `@lobechat/chat-adapter-line` | LINE Messaging API — built in-repo | | `@lobechat/chat-adapter-qq` | QQ Bot — built in-repo | | `@lobechat/chat-adapter-wechat` | WeChat (iLink) — built in-repo | | `@lobechat/chat-adapter-wecom` | WeCom AI bot long connection — built in-repo |

## Webhook setup

Each adapter exposes a webhook handler via `bot.webhooks.{platform}`. Wire these to your HTTP framework's routes (e.g. Next.js API routes, Hono, Express).

Intended uses

  • Use Chat Sdk when this documented workflow matches the task.

Implementation notes

  • Review the source instructions and adapt inputs before running the workflow.

Try it, then tell us how it went

A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.