Complete skill package for Hermes Agent to send interactive cards with buttons in Feishu.
feishu-buttons/
├── SKILL.md # This documentation
├── src/ # Python source files
│ ├── approval.py # Main approval workflow with buttons
│ ├── builder.py # Card building utilities
│ └── cardkit.py # Card sending helpers
└── scripts/ # Utility scripts (optional)
skills/social-media/ directorysrc/ should be accessible from your Hermes installationhermes_feishu_plugin to be installed for full functionalityFeishu interactive cards use a JSON structure:
{
"config": {"wide_screen_mode": true},
"header": {
"title": {"content": "Title", "tag": "plain_text"},
"template": "orange"
},
"elements": [
{"tag": "markdown", "content": "Message content"},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {"tag": "plain_text", "content": "Button Label"},
"type": "primary",
"value": {"action": "value", "data": "payload"}
}
]
}
]
}
| type | Color | Use Case |
|---|---|---|
| ------ | ------- | ---------- |
primary | Blue | Main action |
default | Grey | Secondary action |
danger | Red | Destructive action |
The value field in a button is passed back when clicked:
"value": {
"hermes_action": "approve_once",
"approval_id": "123",
"session_key": "session123",
"chat_id": "chat123"
}
from src.approval import send_approval_card
card = {
"config": {"wide_screen_mode": True},
"header": {
"title": {"content": "⚠️ Confirm Action", "tag": "plain_text"},
"template": "orange"
},
"elements": [
{"tag": "markdown", "content": "Do you want to proceed?"},
{
"tag": "action",
"actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "✅ Confirm"}, "type": "primary", "value": {"action": "confirm"}},
{"tag": "button", "text": {"tag": "plain_text", "content": "❌ Cancel"}, "type": "danger", "value": {"action": "cancel"}}
]
}
]
}
await adapter.send_card(chat_id, card)
async def handle_callback(callback_data):
action = callback_data.get("action")
if action == "confirm":
# Process confirmation
pass
elif action == "cancel":
# Process cancellation
pass
Main implementation for approval workflow with buttons:
send_exec_approval() - Send approval card with buttonshandle_card_action() - Process button click callbacksupdate_approval_card() - Update card after actionCard building utilities:
build_streaming_pre_answer_card() - Build streaming response cardbuild_complete_card() - Build final response cardsplit_reasoning_text() - Extract reasoning from responseLow-level card sending:
send_interactive_card() - Send interactive cardpatch_interactive_card() - Update existing cardhermes_feishu_plugin (for Feishu adapter)json (standard library)asyncio (standard library)This skill is specifically designed for Feishu (Lark) platform. For other messaging platforms:
Each platform has its own message format for interactive elements.
共 2 个版本