飞书多 Agent 消息发送技能。让 Ass/Ops 用自己的飞书应用发送消息(群聊/私聊),解决 open_id 应用隔离问题。
bash
# 获取用户 open_id(从当前 Agent 网关日志)
journalctl --user -u openclaw-gateway-ass.service | grep "received message from"
# Ass 发送私聊消息
/home/admin/.openclaw/workspace-ass/skills/feishu-send-message/send.sh \
ass <open_id> open_id "消息内容"
# Ass 发送群聊消息
/home/admin/.openclaw/workspace-ass/skills/feishu-send-message/send.sh \
ass oc_88fbbe55e37eca3c3339b2f4bae1a8a9 chat_id "群聊消息"
# Ops 发送私聊消息
/home/admin/.openclaw/workspace-ops/skills/feishu-send-message/send.sh \
ops <open_id> open_id "运维消息"
bash
# 读取当前 Agent 配置(以 Ass 为例)
APP_ID=$(jq -r '.channels.feishu.appId' ~/.openclaw/openclaw-ass.json)
APP_SECRET=$(jq -r '.channels.feishu.appSecret' ~/.openclaw/openclaw-ass.json)
# 获取 token
TOKEN=$(curl -s -X POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal/ \
-H 'Content-Type: application/json' \
-d "{\"app_id\":\"$APP_ID\",\"app_secret\":\"$APP_SECRET\"}" | jq -r '.tenant_access_token')
# 发送私聊消息
curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d "{\"receive_id\":\"ou_xxx\",\"msg_type\":\"text\",\"content\":\"{\\\"text\\\":\\\"消息内容\\\"}\"}"
# 发送群聊消息
curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d "{\"receive_id\":\"oc_xxx\",\"msg_type\":\"text\",\"content\":\"{\\\"text\\\":\\\"群聊消息\\\"}\"}"
参数说明示例agentAgent 类型: ass 或 ops``asstarget目标 ID(open_id 或 chat_id)<open_id> 或 <chat_id>msg_type消息类型: open_id(私聊)或 chat_id(群聊)open_idmessage消息内容你好,这是测试消息
参数Ass 值Ops 值说明App IDcli_a924c897d4b89ceb``cli_a924d0d16bf99cee当前 Agent 应用的 IDApp Secret从配置文件读取从配置文件读取当前 Agent 应用的密钥用户 open_id从日志获取从日志获取当前 Agent 应用中的用户 ID群聊 chat_idoc_88fbbe55e37eca3c3339b2f4bae1a8a9同左群聊 ID(应用通用)
从当前 Agent 网关日志获取:
bash
# Ass
journalctl --user -u openclaw-gateway-ass.service | grep "received message from"
# Ops
journalctl --user -u openclaw-gateway-ops.service | grep "received message from"
"{\"text\":\"消息内容\"}"~/.openclaw/openclaw-ass.json~/.openclaw/openclaw-ops.json~/.openclaw/openclaw-boss.json脚本位置: /home/admin/.openclaw/workspace-{agent}/skills/feishu-send-message/send.sh
bash
#!/bin/bash
# 参数:$1=agent (ass/ops), $2=target (open_id 或 chat_id), $3=msg_type (open_id/chat_id), $4=message
AGENT=$1
TARGET=$2
MSG_TYPE=$3
MESSAGE=$4
# 读取配置
APP_ID=$(jq -r ".channels.feishu.appId" ~/.openclaw/openclaw-${AGENT}.json)
APP_SECRET=$(jq -r ".channels.feishu.appSecret" ~/.openclaw/openclaw-${AGENT}.json)
# 获取 token
TOKEN=$(curl -s -X POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal/ \
-H 'Content-Type: application/json' \
-d "{\"app_id\":\"$APP_ID\",\"app_secret\":\"$APP_SECRET\"}" | jq -r '.tenant_access_token')
# 发送消息
curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=${MSG_TYPE}" \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d "{\"receive_id\":\"$TARGET\",\"msg_type\":\"text\",\"content\":\"{\\\"text\\\":\\\"$MESSAGE\\\"}\"}" | jq '.data.message_id'