跳到正文
cccskills
免费在 GitHub 公开中文介绍

chat-sdk

使用 `chat` SDK 和 TypeScript 为多个聊天平台构建机器人,处理提及、斜杠命令、互动卡片、表单、Webhook 和流式回复。

原文查看原文说明

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

lobehub/lobehub星标 83,502(GitHub 83,502 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 构建支持多个聊天平台的机器人
  • 响应提及或斜杠命令
  • 发布带互动按钮的卡片
  • 将生成文本逐步发送到聊天

中文介绍

功能

使用 chat SDK,可以通过同一套 TypeScript 代码为多个聊天服务构建机器人。Slack、Teams、Google Chat、Discord、GitHub 和 Linear 等平台适配器支持机器人响应提及、斜杠命令、消息、表情回应和按钮操作。SDK 还支持向对话线程发消息、订阅线程、保存状态以及连接 Webhook。卡片中可以加入按钮和选择项,也可以将异步生成的文本逐步传送到聊天中。

适用场景

希望在多个聊天服务中提供相同机器人功能,或开发能够响应对话内操作的机器人时,可以使用这套指南。需要加入表单、卡片审批等互动流程,或在 AI 回复生成过程中持续发送内容时也适用。

使用示例

  • “请构建一个能在被提及的线程中回复的机器人。”
  • “请发布带按钮的卡片,并处理用户的选择。”
  • “请把生成中的文本逐步发送到聊天中。”

注意事项

需要安装 chat 和相应的平台适配器包。开始实现前,请查看 node_modules/chat/docs/ 中的相关文档和类型定义。模态窗口的说明面向 Slack。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
B部分不足涉及 Webhook 和状态存储,并展示令牌变量,但安全说明有限。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足需要 `chat`、适配器、用于 Webhook 的 HTTP 框架及可选状态存储配置。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月26日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md6.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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

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

HandlerTrigger
onNewMentionBot @-mentioned in unsubscribed thread
onSubscribedMessageAny 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
onAssistantThreadStartedSlack Assistants API thread opened
onAppHomeOpenedSlack App Home tab opened

Streaming

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

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.

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.

PackagePurpose
chatCore SDK
@chat-adapter/discordDiscord
@chat-adapter/slackSlack
@chat-adapter/telegramTelegram
@chat-adapter/state-ioredisioredis state
@lobechat/chat-adapter-feishuLark/Feishu — built in-repo (packages/chat-adapter-feishu), not from @chat-adapter/
@lobechat/chat-adapter-imessageiMessage via BlueBubbles — built in-repo
@lobechat/chat-adapter-lineLINE Messaging API — built in-repo
@lobechat/chat-adapter-qqQQ Bot — built in-repo
@lobechat/chat-adapter-wechatWeChat (iLink) — 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).

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

acceptance

免费有简介

通过实际操作产品验证交付内容,记录用户可查看的证据,并发布验收报告。可检查已有验证计划或创建检查项,选择合适的操作界面,并使用 `lh` CLI 发布结果。

  • 实际检查更改后的产品行为
  • 收集截图或其他验证证据
  • 编写验证计划和报告
lobehub/lobehub8.4万2026年10月26日 更新

add-model-provider

免费有简介

本技能指导在 LobeHub 中接入 AI 模型提供商,涵盖运行时、模型信息、设置、品牌展示、文档和验收,并帮助判断新增模型是否需要新的提供商集成。

  • 为 LobeHub 接入新的 AI 模型提供商
  • 更新提供商设置说明或介绍
  • 判断添加模型是否需要新的提供商集成
lobehub/lobehub8.4万2026年10月26日 更新

add-setting-env

免费有简介

本技能指导如何用服务器端环境变量设置用户偏好默认值,涵盖变量校验、服务器配置、写入用户状态,以及更新 `.env.example` 和自托管文档。

  • 通过环境变量设置用户偏好默认值
  • 将设置接入服务器配置和用户状态
  • 更新环境变量示例及文档
lobehub/lobehub8.4万2026年10月26日 更新

agent-runtime-hooks

免费有简介

说明如何在智能体执行步骤、工具调用、人工审批、上下文压缩和子智能体调用时注册钩子。钩子可观察事件、模拟本地工具结果,也可通过 Webhook 按配置策略允许或拒绝工具调用。

  • 记录智能体步骤和错误
  • 测试时模拟工具结果
  • 通过 Webhook 允许或拒绝工具调用
lobehub/lobehub8.4万2026年10月26日 更新

agent-signal

免费有简介

此技能用于为智能体设计事件驱动的后台工作流,划分来源、信号、动作和策略的职责,并处理异步交接、去重、执行范围、完成记录与运行观测。

  • 添加事件触发的后台任务
  • 将工作移出对话请求
  • 防止动作重复执行
lobehub/lobehub8.4万2026年10月26日 更新

agent-testing-bot

免费有简介

本技能在 macOS 桌面聊天应用中测试机器人频道:打开应用、进入频道或联系人、发送消息、等待回复并截图。支持 Discord、Slack、Telegram、微信、飞书和 QQ;iMessage 使用 BlueBubbles 桥接。

  • 检查真实 Discord 频道中的机器人回复
  • 测试 Slack 或 Telegram 的对话流程
  • 记录 macOS 应用中的操作结果
lobehub/lobehub8.4万2026年10月26日 更新

查看 lobehub 的全部技能

报告此技能的问题