通知与机器人集成

InnoClaw 通过机器人适配器支持与消息平台的集成。这使用户可以直接从聊天应用程序与其工作空间进行交互。

支持的渠道

平台

状态码

Webhook 端点

飞书

已支持

/api/bot/feishu

企业微信

已支持

/api/bot/wechat

架构

        sequenceDiagram
    participant User
    participant Platform as Feishu / WeChat
    participant Webhook as InnoClaw Webhook
    participant Processor as Bot Processor
    participant AI as AI Provider

    User->>Platform: Send message
    Platform->>Webhook: POST webhook event
    Webhook->>Processor: Parse & validate
    Processor->>AI: Process with RAG
    AI->>Processor: AI response
    Processor->>Platform: Reply message
    Platform->>User: Show response
    

飞书机器人

设置

  1. 在飞书开放平台创建飞书应用

  2. 配置以下环境变量:

FEISHU_BOT_ENABLED=true
FEISHU_APP_ID=cli_your_app_id
FEISHU_APP_SECRET=your_app_secret
FEISHU_VERIFICATION_TOKEN=your_verification_token
FEISHU_ENCRYPT_KEY=your_encrypt_key
FEISHU_PUSH_SECRET=your_push_secret
  1. 在飞书应用配置中设置 Webhook URL:

    https://your-domain.com/api/bot/feishu
    

Connection Modes

Feishu supports two connection modes:

模式

描述

HTTP Webhook

Feishu sends HTTP POST events to your webhook URL. Requires public URL.

WebSocket

Long-lived connection using @larksuiteoapi/node-sdk WSClient. Started automatically in instrumentation.ts. No public URL needed.

功能特性

  • 接收并回复文本消息

  • Download and process file attachments (text files < 100 KB)

  • Audio message transcription

  • Interactive card responses with real-time agent progress tracking

  • Agent mode integration (full tool access)

  • 支持加密事件负载

  • 自动 Webhook 验证

Bot Commands

Users can interact with the bot using slash commands:

Command

Parameters

描述

/workspace

<path> (optional)

Bind a workspace directory, or show the current binding

/mode

<agent|plan|ask>

Switch the agent mode for this chat

/status

—

Show chat state (workspace, mode, history count, chat ID)

/clear

—

Clear conversation history (preserves workspace and mode)

/help

—

Show available commands and modes

Agent Modes in Feishu

模式

Tools Available

描述

agent

All tools (bash, readFile, writeFile, grep, kubectl, etc.)

Full autonomous execution

plan

readFile, listDirectory, grep

Read-only analysis and planning

ask

readFile, listDirectory, grep

Simple question answering

Interactive Cards

The Feishu bot uses interactive cards for rich progress display:

  • Progress Card — Shows real-time agent execution progress with tool call status

  • Final Card — Displays completed execution with tool call summary and response text

  • Error Card — Shows agent execution error with details

  • Command Response Card — Used for slash command responses

Push API

The Push API enables sending messages from the web application to Feishu chats:

POST /api/bot/feishu/push
Authorization: Bearer <FEISHU_PUSH_SECRET>

Request Body:

{
  "chatId": "oc_xxxxxxxxxxxx",
  "title": "Agent Message",
  "content": "Message content here",
  "type": "card"
}

This enables bidirectional communication between the web UI and Feishu. The chatId can be obtained via the /status command.

事件处理

飞书机器人处理以下事件类型:

事件

描述

url_verification

初始 Webhook URL 验证

im.message.receive_v1

来自用户的传入消息

企业微信机器人

设置

  1. 在企业微信管理后台创建应用

  2. 配置以下环境变量:

WECHAT_BOT_ENABLED=true
WECHAT_CORP_ID=your_corp_id
WECHAT_CORP_SECRET=your_corp_secret
WECHAT_TOKEN=your_token
WECHAT_ENCODING_AES_KEY=your_aes_key
WECHAT_AGENT_ID=your_agent_id
  1. 在企业微信应用配置中设置 Webhook URL:

    https://your-domain.com/api/bot/wechat
    

功能特性

  • 接收并回复文本消息

  • 支持明文和加密两种消息模式

  • Webhook 签名验证

  • 自动访问令牌管理

验证模式

企业微信支持两种 Webhook 验证模式:

模式

使用的参数

明文

msg_signature、timestamp、nonce 配合 SHA-1 签名

加密

AES-256-CBC 加密消息体

通用配置

工作空间绑定

机器人集成使用已配置工作空间的 RAG 流水线处理消息。机器人处理器将传入消息路由到相应的工作空间和 AI 提供商。

For Feishu, use the /workspace <path> command to bind a workspace. New chats are automatically bound to the first directory in WORKSPACE_ROOTS.

安全性

  • 所有 Webhook 请求都通过平台特定的签名/令牌验证进行校验

  • 两个平台均支持加密消息模式

  • API 密钥和密钥仅存储在服务器端,永远不会暴露给客户端

通知负载格式

机器人响应遵循各平台的原生消息格式:

Feishu (Interactive Card):

{
  "msg_type": "interactive",
  "card": {
    "header": { "title": { "tag": "plain_text", "content": "Agent Response" } },
    "elements": [{ "tag": "markdown", "content": "AI response content" }]
  }
}

Feishu (Text):

{
  "msg_type": "text",
  "content": {
    "text": "AI response based on your workspace files"
  }
}

企业微信:

<xml>
  <MsgType>text</MsgType>
  <Content>AI response based on your workspace files</Content>
</xml>