Files
xinmi/docs/wiki/集成扩展/IM集成开发.md
T
yawan f7fc992f57
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
2026-09-22 16:19:06 +08:00

4.7 KiB
Raw Blame History

title, tags, aliases, source
title tags aliases source
IM集成开发
集成扩展
IM
企微
飞书
Lark
Slack
Telegram
钉钉
Mattermost
IM集成
IM开发
企业微信
即时通讯
IM集成开发文档.md

IM 集成开发

WeKnora 的 IM 集成模块将企业即时通讯平台(企业微信、飞书、Lark、Slack、Telegram、钉钉、Mattermost)接入 WeKnora 知识问答管道,支持在 IM 中直接向 AI 提问并获得实时流式回答。

IM 渠道绑定到 Agent,一个 Agent 可接入多个 IM 渠道。

IM 渠道中的 Agent 可以使用 MCP 工具 和 Skills 技能

支持的平台

平台 WebSocket 模式 Webhook 模式 流式输出
企业微信 ✅ ✅ ✅
飞书 ✅ ✅ ✅ (CardKit)
Lark(飞书国际版) ✅ ✅ ✅ (CardKit)
Slack ✅ (Socket Mode) ✅ (Events API) ✅
Telegram ✅ (长轮询) ✅ ✅
钉钉 ✅ (Stream) ✅ ✅ (AI 卡片)
Mattermost — ✅ ✅

快速接入指南

前置条件

  • WeKnora 已部署并运行
  • 已创建至少一个 Agent(自定义智能体)
  • Agent 已配置好模型和知识库

Agent 配置模型参见 内置模型管理

企业微信接入

提供两种模式:

  • WebSocket 模式(智能机器人,推荐)— 无需公网域名
  • Webhook 模式(自建应用)— 需要公网回调地址

飞书接入

  • WebSocket 模式(推荐)— 无需公网域名
  • Webhook 模式 — 需要公网回调地址

飞书同时也是数据源导入的支持平台,参见 数据源导入开发

Lark 接入

Lark 是飞书的国际版,IM 接口一致,与飞书共用同一套适配器。接入步骤基本相同,但开放平台 与权限清单不同:

权限不可套用飞书的清单:飞书清单混入了数据源连接器(Wiki 同步)用的权限,其中部分在 Lark 并不存在,整份导入会失败。Lark 只需 IM 相关的 6 项,见 IM集成开发文档 — Lark 权限配置。

两朵云的应用互不通用,凭证只在创建它的那朵云上有效。

Slack 接入

  • Socket Mode(推荐)— 无需公网域名
  • Events API — 需要公网回调地址

Telegram 接入

  • 长轮询模式(推荐)— 无需公网域名
  • Webhook 模式 — 需要 HTTPS 公网回调

钉钉接入

  • Stream 模式(推荐)— 无需公网域名
  • Webhook 模式 — 需要公网回调地址

Mattermost 接入

  • 仅支持 Webhook 模式(出站 Webhook + REST API v4)

架构设计

系统采用 Adapter Pattern,每个平台实现 im.Adapter 接口,通过 AdapterFactory 动态创建。核心设计模式包括:

模式 用途
Adapter Pattern 统一不同 IM 平台的差异
Factory Pattern 从数据库渠道配置动态创建 Adapter
Command Pattern 可插拔的斜杠指令系统
Producer-Consumer QA 队列 + Worker Pool

斜杠指令系统

指令 说明
/help 显示所有可用指令
/info 查看当前绑定智能体信息
/search 对知识库执行混合检索
/stop 取消当前 QA 请求
/clear 清空当前对话记忆

扩展新平台

接入新的 IM 平台只需 3 步:

  1. 实现 im.Adapter 接口(可选 StreamSender、FileDownloader)
  2. 注册适配器工厂
  3. 前端添加平台选项

扩展开发模式与 添加网络搜索引擎 和 集成向量数据库 类似

相关主题


反向链接