@zhouyue009/infoflow
v1.0.19
Published
InfoFlow channel plugin for Moltbot
Downloads
176
Readme
InfoFlow Plugin for Clawdbot
This plugin enables integration between Clawdbot and InfoFlow, an internal IM application.
Features
- Send and receive messages via InfoFlow
- 单聊消息支持 - 机器人与用户的一对一聊天
- 群聊消息支持 - 机器人在群组中接收和发送消息
- 消息去重机制 - 防止重复处理(5分钟内相同消息ID自动去重)
- Webhook-based message receiving
- 支持 TEXT、LINK、AT 等多种消息类型解析
- Polling mechanism as fallback option
- 🆕 统一日志系统 - 自动 TraceId 追踪 + 北京时间格式 + 结构化日志
Configuration
The following parameters need to be configured after installing the plugin:
serverUrl: The base URL of your InfoFlow server (e.g., http://api.im.baidu.com)apiKey: App Key for authentication (请替换为你的实际 appKey)appSecret: App Secret for authentication (请替换为你的实际 appSecret)encodingAESKey: EncodingAESKey for decrypting webhook messages (empty string if not required)webhookToken: Webhook callback token (configured in robot platform)webhookPath: Path where InfoFlow will send webhook notifications (default: /webhooks/infoflow)webhookPort: Port for webhook server to listen on (default: 18790)pollingInterval: Polling interval in milliseconds (set to -1 to disable polling)agentId: InfoFlow Agent ID (default: "5035")allowFrom: List of allowed user IDs (empty array means allow all)
配置示例: 参见 config.example.json 文件
Installation
方式 1: 使用 npm 包安装
- 下载插件包
infoflow-x.x.x.tgz - 安装插件:
clawdbot plugins install /path/to/infoflow-x.x.x.tgz方式 2: 本地开发安装
- Clone 本项目
- 编译插件(需要 Clawdbot SDK):
npx tsc- 安装到本地:
clawdbot plugins install .Configuration
安装后配置插件(编辑 Clawdbot 配置文件或使用 TUI):
- serverUrl: "http://apiin.im.baidu.com"
- apiKey: "7f8bab41660b25dd458084b7ca45d1be"
- appSecret: "WEasLTNJ4eE7QWyjNUBxUfbyiD8yqeLo"
- encodingAESKey: "" (empty string if not set in your InfoFlow system)
- webhookPath: "/webhooks/infoflow" (default)
- webhookPort: 18790 (default, can be changed if port conflicts)
- Set up the webhook in your InfoFlow application to point to your Clawdbot instance:
- Webhook URL:
http://your-server-ip:18790/webhooks/infoflow - For local testing:
http://127.0.0.1:18790/webhooks/infoflow
- Webhook URL:
- Authorize the connection between the systems
Usage
Once configured, the plugin will:
- Listen for incoming messages via webhooks (preferred method)
- Optionally poll for messages if webhook is unavailable (fallback)
- Forward outgoing messages from Clawdbot to InfoFlow users
- Handle text messages and basic interactions
发送消息
单聊消息
发送消息到用户时,目标可以是:
- 直接使用用户ID:
userId - 使用前缀:
user:userId
群聊消息
发送消息到群组时,使用 group: 前缀:
group:groupId
接收消息
单聊消息回调
单聊消息通过 webhook 接收,消息格式:
{
"MsgType": "text",
"FromUserId": "user001",
"FromUserName": "用户名",
"Content": "消息内容",
"CreateTime": 1234567890
}群聊消息回调
群聊消息通过 webhook 接收,消息体是加密的。解密后格式:
{
"eventtype": "receive_message",
"groupid": "群组ID",
"message": {
"header": {
"fromuserid": "发送者ID",
"messageid": "消息ID",
"ctime": 1234567890000
},
"body": [
{"type": "TEXT", "content": "消息内容"},
{"type": "AT", "userid": "被@的用户ID"},
{"type": "LINK", "label": "链接标签", "url": "链接地址"}
]
}
}API 端点
| 功能 | 端点 |
|------|------|
| 发送单聊消息 | /api/v1/app/message/send |
| 发送群聊消息 | /api/v1/robot/msg/groupmsgsend |
| 获取访问令牌 | /api/v1/auth/app_access_token |
测试脚本
插件包含以下测试脚本:
test-webhook.sh- 测试 webhook 基本功能test-group-message.sh- 测试群聊消息回调test-group-logic.mjs- 测试核心逻辑(消息解析、去重等)test-logger.ts- 测试日志系统(运行:npx tsx test-logger.ts)
日志系统
插件现在使用统一的日志系统,所有日志包含:
- TraceId:唯一追踪 ID,用于关联同一操作的所有日志
- 北京时间:格式
YYYY-MM-DD HH:mm:ss.SSS(UTC+8) - 日志级别:DEBUG, INFO, WARN, ERROR
- 结构化元数据:JSON 格式,便于搜索和分析
详细文档请参阅:日志系统使用指南
日志示例:
[2026-02-02 22:25:28.474] [ml59i1lm-17d24f4b6852] [INFO] [infoflow:message] 📥 Processing incoming message | meta: {"type":"group","from":"user123","text":"你好"}
[2026-02-02 22:25:28.474] [ml59i1lm-17d24f4b6852] [INFO] [infoflow:message] 🤖 Sending to clawdbot agent via gateway...
[2026-02-02 22:25:28.474] [ml59i1lm-17d24f4b6852] [INFO] [infoflow:message] ✅ Reply sent successfullyAPI Credentials Tested
Successfully tested with the following credentials:
- AppKey: 7f8bab41660b25dd458084b7ca45d1be
- AppSecret: WEasLTNJ4eE7QWyjNUBxUfbyiD8yqeLo
- Retrieved access token: at_4bd3c729-ac7d-498b-8684-7b6022f65001 (valid for 7200 seconds)
