{"data":{"slug":"github-lobehub-lobehub-agents-skills-chat-sdk-96655623642d","title":"Build Multi-Platform Chat Bots with Chat SDK","summary":"Create bots for Slack, Teams, Google Chat, Discord, GitHub, and Linear using a unified TypeScript SDK. Write bot logic once and deploy across platforms. The deliverable includes bot logic and integration with platform-specific adapters.","url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-chat-sdk-96655623642d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-lobehub-lobehub-agents-skills-chat-sdk-96655623642d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-chat-sdk-96655623642d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-chat-sdk-96655623642d\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Always read the bundled documentation in `node_modules\/chat\/docs\/` and TypeScript types in `node_modules\/chat\/dist\/` before writing code. Setup requires importing the `chat` package and configuring platform-specific adapters like `createSlackAdapter` with environment variables such as `SLACK_BOT_TOKEN` and `SLACK_SIGNING_SECRET`.","instructions":"---\nname: chat-sdk\ndescription: 'Use for multi-platform bots built with chat SDK: webhooks, mentions, slash commands, cards, modals and streaming.'\nuser-invocable: false\n---\n\n# Chat SDK\n\nUnified TypeScript SDK for building chat bots across Slack, Teams, Google Chat, Discord, GitHub, and Linear. Write bot logic once, deploy everywhere.\n\n## Critical: Read the bundled docs\n\nThe `chat` package ships with full documentation in `node_modules\/chat\/docs\/` and TypeScript source types. **Always read these before writing code:**\n\n```\nnode_modules\/chat\/docs\/           # Full documentation (MDX files)\nnode_modules\/chat\/dist\/           # Built types (.d.ts files)\n```\n\nKey docs to read based on task:\n\n- `docs\/getting-started.mdx` \u2014 setup guides\n- `docs\/usage.mdx` \u2014 event handlers, threads, messages, channels\n- `docs\/streaming.mdx` \u2014 AI streaming with AI SDK\n- `docs\/cards.mdx` \u2014 JSX interactive cards\n- `docs\/actions.mdx` \u2014 button\/dropdown handlers\n- `docs\/modals.mdx` \u2014 form dialogs (Slack only)\n- `docs\/adapters.mdx`, `docs\/platform-adapters.mdx` \u2014 adapter overview and platform-specific setup\n- `docs\/state-adapters.mdx` \u2014 state adapter config (Redis, ioredis, memory)\n\nAlso read the TypeScript types from `node_modules\/chat\/dist\/` to understand the full API surface.\n\n## Quick start\n\n```typescript\nimport { Chat } from 'chat';\nimport { createSlackAdapter } from '@chat-adapter\/slack';\nimport { createRedisState } from '@chat-adapter\/state-redis';\n\nconst bot = new Chat({\n  userName: 'mybot',\n  adapters: {\n    slack: createSlackAdapter({\n      botToken: process.env.SLACK_BOT_TOKEN!,\n      signingSecret: process.env.SLACK_SIGNING_SECRET!,\n    }),\n  },\n  state: createRedisState({ url: process.env.REDIS_URL! }),\n});\n\nbot.onNewMention(async (thread) => {\n  await thread.subscribe();\n  await thread.post(\"Hello! I'm listening to this thread.\");\n});\n\nbot.onSubscribedMessage(async (thread, message) => {\n  await thread.post(`You said: ${message.text}`);\n});\n```\n\n## Core concepts\n\n- **Chat** \u2014 main entry point, coordinates adapters and routes events\n- **Adapters** \u2014 platform-specific (Slack, Teams, GChat, Discord, GitHub, Linear)\n- **State** \u2014 pluggable persistence (Redis for prod, memory for dev)\n- **Thread** \u2014 conversation thread with `post()`, `subscribe()`, `startTyping()`\n- **Message** \u2014 normalized format with `text`, `formatted` (mdast AST), `raw`\n- **Channel** \u2014 container for threads, supports listing and posting\n\n## Event handlers\n\n| Handler                    | Trigger                                           |\n| -------------------------- | ------------------------------------------------- |\n| `onNewMention`             | Bot @-mentioned in unsubscribed thread            |\n| `onSubscribedMessage`      | Any message in subscribed thread                  |\n| `onNewMessage(regex)`      | Messages matching pattern in unsubscribed threads |\n| `onSlashCommand(\"\/cmd\")`   | Slash command invocations                         |\n| `onReaction(emojis)`       | Emoji reactions added\/removed                     |\n| `onAction(actionId)`       | Button clicks and dropdown selections             |\n| `onAssistantThreadStarted` | Slack Assistants API thread opened                |\n| `onAppHomeOpened`          | Slack App Home tab opened                         |\n\n## Streaming\n\nPass any `AsyncIterable<string>` to `thread.post()`. Works with AI SDK's `textStream`:\n\n```typescript\nimport { ToolLoopAgent } from 'ai';\nconst agent = new ToolLoopAgent({ model: 'anthropic\/claude-sonnet-5' });\n\nbot.onNewMention(async (thread, message) => {\n  const result = await agent.stream({ prompt: message.text });\n  await thread.post(result.textStream);\n});\n```\n\n## Cards (JSX)\n\nSet `jsxImportSource: \"chat\"` in tsconfig. Components: `Card`, `CardText`, `Button`, `Actions`, `Fields`, `Field`, `Select`, `SelectOption`, `Image`, `Divider`, `LinkButton`, `Section`, `RadioSelect`.\n\n```tsx\nawait thread.post(\n  <Card title=\"Order #1234\">\n    <CardText>Your order has been received!<\/CardText>\n    <Actions>\n      <Button id=\"approve\" style=\"primary\">\n        Approve\n      <\/Button>\n      <Button id=\"reject\" style=\"danger\">\n        Reject\n      <\/Button>\n    <\/Actions>\n  <\/Card>,\n);\n```\n\n## Packages\n\n`chat` and the `@chat-adapter\/*` packages are an external SDK this repo\nconsumes (pinned via semver range in `package.json`), not something built or\nversioned here \u2014 there's no Changesets\/release flow to document for them.\n\n| Package                           | Purpose                                                                                 |\n| --------------------------------- | --------------------------------------------------------------------------------------- |\n| `chat`                            | Core SDK                                                                                |\n| `@chat-adapter\/discord`           | Discord                                                                                 |\n| `@chat-adapter\/slack`             | Slack                                                                                   |\n| `@chat-adapter\/telegram`          | Telegram                                                                                |\n| `@chat-adapter\/state-ioredis`     | ioredis state                                                                           |\n| `@lobechat\/chat-adapter-feishu`   | Lark\/Feishu \u2014 built in-repo (`packages\/chat-adapter-feishu`), not from `@chat-adapter\/` |\n| `@lobechat\/chat-adapter-imessage` | iMessage via BlueBubbles \u2014 built in-repo                                                |\n| `@lobechat\/chat-adapter-line`     | LINE Messaging API \u2014 built in-repo                                                      |\n| `@lobechat\/chat-adapter-qq`       | QQ Bot \u2014 built in-repo                                                                  |\n| `@lobechat\/chat-adapter-wechat`   | WeChat (iLink) \u2014 built in-repo                                                          |\n\n## Webhook setup\n\nEach 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).\n","use_cases":["Build a Slack bot that responds to @mentions and messages","Create a GitHub bot that reacts to issues and pull requests","Develop a Discord bot that handles commands and reactions"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/lobehub\/lobehub\/blob\/54382b5c8e81544da454fa6d7b50f461a562c1ee\/.agents\/skills\/chat-sdk\/SKILL.md","source_commit":"54382b5c8e81544da454fa6d7b50f461a562c1ee","license":null,"version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T11:00:41.000000Z","updated_at":"2026-11-22T11:17:05.000000Z","seo_title":"Build Multi-Platform Chat Bots with Chat SDK","seo_description":"Create bots for Slack, Teams, Google Chat, Discord, GitHub, and Linear with a unified TypeScript SDK.","seo_keywords":["chat bot development","multi-platform bot SDK","Slack bot creation","Discord bot API","GitHub bot integration"]}}