搜索

PythonReactSEOPDF
OpenClaw

feishu-card

飞书互动卡片发送技能(国际版 Feishu 兼容)。当需要发送格式丰富的飞书卡片消息时使用。支持标题、Markdown 内容、颜色主题。关键:必须使用 schema 2.0 格式 + 双重 JSON stringify,否则国际版飞书(Feishu)无法渲染。

dadaniya990 来源安装数☆ 0 仓库 Stars

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

SkillHub CLI

skillhub install dadaniya99/xiaolongxia-feishu-card

打开来源仓库,查看说明和兼容环境后,按来源提供的命令或步骤安装。

将来源链接提供给你的 Agent,让它先读取说明、核对依赖,并向你说明将执行的安装步骤。

查看来源 ↗使用指南

技能说明

飞书互动卡片发送技能

核心要点(必读)

飞书卡片有新旧两种格式:

  • 旧版 components 格式:部分版本不兼容,显示"请升级至最新版本客户端"
  • schema 2.0 格式:✅ 推荐,飞书 7.x 均支持

统一用 schema 2.0 即可,不管飞书是中文界面还是英文界面都能用。

关键:双重 JSON.stringify

import json

card = { ... }  # 卡片对象
content = json.dumps(json.dumps(card))  # 必须 dumps 两次!

一次 stringify 不够,飞书 API 的 content 字段要求是 JSON 字符串。

卡片结构(schema 2.0)

{
  "schema": "2.0",
  "header": {
    "title": {
      "tag": "plain_text",
      "content": "标题文字"
    },
    "template": "blue"
  },
  "body": {
    "elements": [
      {
        "tag": "markdown",
        "content": "**加粗** 普通文字\n\n支持换行"
      }
    ]
  }
}
header.template 颜色选项
  • blue — 蓝色(默认推荐)
  • green — 绿色
  • red — 红色
  • orange — 橙色
  • purple — 紫色
  • grey — 灰色
body.elements 支持的 tag
  • markdown — Markdown 文本(支持 加粗、斜体、代码、链接)
  • hr — 分割线:{"tag": "hr"}
  • note — 底部备注

发送方式

方法一:用脚本(推荐)
python3 /root/.openclaw/workspace/skills/feishu-card/scripts/send_card.py \
  --open-id "ou_xxxx" \
  --title "标题" \
  --content "**内容** 支持 Markdown" \
  --template "blue"
方法二:用 message tool

直接调用 message tool,msg_type 需要写 interactive,content 需要双重 stringify(先序列化卡片对象,再序列化整个字符串)。

方法三:curl(手动)
APP_SECRET=$(cat /root/.openclaw/openclaw.json | python3 -c "import json,sys; d=json.load(sys.stdin); print(d['channels']['feishu']['appSecret'])")
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\":\"cli_a9f5877b3378dbd8\",\"app_secret\":\"$APP_SECRET\"}" \
  | python3 -c "import json,sys; print(json.load(sys.stdin)['tenant_access_token'])")

python3 -c "
import json
card = {
    'schema...

来源信息

Source
github
Repository
openclaw/skills
Path
skills/dadaniya99/xiaolongxia-feishu-card
Version
—
Commit
f38fba2d7a6c6dde79a14940c303d73b17607c77
分类来源
rules
状态
active
可见性
public

这些信息来自收录时的来源分析,可能滞后;使用前请核对最新来源文件。

来源内容

SKILL.md
# 飞书互动卡片发送技能

## 核心要点(必读)

飞书卡片有新旧两种格式:
- **旧版 components 格式**:部分版本不兼容,显示"请升级至最新版本客户端"
- **schema 2.0 格式**:✅ 推荐,飞书 7.x 均支持

统一用 schema 2.0 即可,不管飞书是中文界面还是英文界面都能用。

## 关键:双重 JSON.stringify

```python
import json

card = { ... }  # 卡片对象
content = json.dumps(json.dumps(card))  # 必须 dumps 两次!
```

一次 stringify 不够,飞书 API 的 `content` 字段要求是 JSON 字符串。

## 卡片结构(schema 2.0)

```json
{
  "schema": "2.0",
  "header": {
    "title": {
      "tag": "plain_text",
      "content": "标题文字"
    },
    "template": "blue"
  },
  "body": {
    "elements": [
      {
        "tag": "markdown",
        "content": "**加粗** 普通文字\n\n支持换行"
      }
    ]
  }
}
```

### header.template 颜色选项
- `blue` — 蓝色(默认推荐)
- `green` — 绿色
- `red` — 红色
- `orange` — 橙色
- `purple` — 紫色
- `grey` — 灰色

### body.elements 支持的 tag
- `markdown` — Markdown 文本(支持 **加粗**、*斜体*、`代码`、链接)
- `hr` — 分割线:`{"tag": "hr"}`
- `note` — 底部备注

## 发送方式

### 方法一:用脚本(推荐)

```bash
python3 /root/.openclaw/workspace/skills/feishu-card/scripts/send_card.py \
  --open-id "ou_xxxx" \
  --title "标题" \
  --content "**内容** 支持 Markdown" \
  --template "blue"
```

### 方法二:用 message tool

直接调用 `message` tool,`msg_type` 需要写 `interactive`,`content` 需要双重 stringify(先序列化卡片对象,再序列化整个字符串)。

### 方法三:curl(手动)

```bash
APP_SECRET=$(cat /root/.openclaw/openclaw.json | python3 -c "import json,sys; d=json.load(sys.stdin); print(d['channels']['feishu']['appSecret'])")
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\":\"cli_a9f5877b3378dbd8\",\"app_secret\":\"$APP_SECRET\"}" \
  | python3 -c "import json,sys; print(json.load(sys.stdin)['tenant_access_token'])")

python3 -c "
import json
card = {
    'schema...

相关技能

OpenClaw

1password

daggerkun007

Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.