send-feishu
Original:🇺🇸 English
Translated
Use when user says "发到飞书", "飞书通知", "通知飞书", "feishu", "发给我", "私发飞书", or explicitly invokes /send-feishu to send messages, images, or files to Feishu group chat or individual via webhook or API
12installs
Sourcejssfy/k-skills
Added on
NPX Install
npx skill4agent add jssfy/k-skills send-feishuTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Send Feishu Message
Send messages, images, and files to Feishu groups or individuals.
Environment Variables
| Variable | Purpose | Required |
|---|---|---|
| Group Webhook URL | For text/card/image to group |
| App credential | For image/file upload & API send |
| App credential | For image/file upload & API send |
| Group chat ID ( | For API send to group |
| Personal open_id ( | For send to individual |
Decision Logic
Choose the sending method based on content type and target:
Text/Card to group → Webhook (simple, no auth needed)
Image to group → Get token → Upload image → Webhook send image_key
File to group → Get token → Upload file → API send to chat_id
Image/File to person → Get token → Upload resource → API send to open_id
Text/Card to person → Get token → API send to open_idChoosing Format
Use text — simple one-liner (status update, quick note).
Use card — content has title + body, structured data, summary, or report.
Use image — user explicitly asks to send an image file, screenshot, or chart.
Use file — user asks to send .md/.pdf/.doc/.xls etc., or content is too long for card display.
Send to individual — user says "发给我", "私发", "发到我的飞书", or specifies a person.
Step A: Get tenant_access_token
Required for image upload, file upload, and API message sending. Skip this step if only sending text/card via Webhook.
bash
curl -s -X POST 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal' \
-H 'Content-Type: application/json' \
-d '{"app_id":"'"$FEISHU_APP_ID"'","app_secret":"'"$FEISHU_APP_SECRET"'"}'Response:
{"code":0,"msg":"ok","tenant_access_token":"t-xxx","expire":7200}Extract the token and store in a variable for subsequent steps.
Step B: Upload Image (get image_key)
Required when sending an image. Supports JPEG/PNG/WEBP/GIF/TIFF/BMP/ICO, max 10MB.
bash
curl -s -X POST 'https://open.feishu.cn/open-apis/im/v1/images' \
-H "Authorization: Bearer $TOKEN" \
-F 'image_type="message"' \
-F 'image=@"/path/to/image.png"'Response:
{"code":0,"data":{"image_key":"img_xxx"}}Step C: Upload File (get file_key)
Required when sending a file. Max 30MB.
bash
curl -s -X POST 'https://open.feishu.cn/open-apis/im/v1/files' \
-H "Authorization: Bearer $TOKEN" \
-F 'file_type="stream"' \
-F 'file_name="report.md"' \
-F 'file=@"/path/to/file"'file_typeopusmp4pdfdocxlspptstreamResponse:
{"code":0,"data":{"file_key":"file_xxx"}}Sending via Webhook
Send Text
bash
curl -s -X POST "$FEISHU_WEBHOOK" -H "Content-Type: application/json" \
-d '{"msg_type":"text","content":{"text":"MESSAGE_HERE"}}'Send Card
Pick header color by sentiment:
- — success, complete, done
green - — warning, attention
orange - — error, failure
red - — info, neutral (default)
blue - — highlight, special
purple
bash
curl -s -X POST "$FEISHU_WEBHOOK" -H "Content-Type: application/json" \
-d '{
"msg_type":"interactive",
"card":{
"header":{"title":{"content":"TITLE","tag":"plain_text"},"template":"COLOR"},
"elements":[{"tag":"div","text":{"content":"BODY_LARK_MD","tag":"lark_md"}}]
}
}'Card body supports lark_md: , , , , for newlines.
**bold***italic*~~strike~~[link](url)\nSend Image via Webhook
After uploading image (Step B) to get :
image_keybash
curl -s -X POST "$FEISHU_WEBHOOK" \
-H "Content-Type: application/json" \
-d '{"msg_type":"image","content":{"image_key":"img_xxx"}}'Sending via API
Use API when sending files, or sending any content to an individual.
Send to Group (chat_id)
bash
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; charset=utf-8" \
-d '{"receive_id":"'"$FEISHU_CHAT_ID"'","msg_type":"MSG_TYPE","content":"CONTENT_JSON_STRING"}'Send to Individual (open_id)
bash
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; charset=utf-8" \
-d '{"receive_id":"'"$FEISHU_USER_OPEN_ID"'","msg_type":"MSG_TYPE","content":"CONTENT_JSON_STRING"}'API Content Formats
The field must be a JSON-encoded string (escaped JSON inside JSON).
contentText:
json
{"receive_id":"ID","msg_type":"text","content":"{\"text\":\"Hello\"}"}Image (after upload):
json
{"receive_id":"ID","msg_type":"image","content":"{\"image_key\":\"img_xxx\"}"}File (after upload):
json
{"receive_id":"ID","msg_type":"file","content":"{\"file_key\":\"file_xxx\"}"}After Sending
Check the response JSON:
- Webhook: → success
{"code":0,"msg":"success"} - API: → success
{"code":0,"msg":"success","data":{...}} - != 0 → report the error:
code- 19001: webhook URL invalid
- 19021: signature check failed
- 19022: IP not whitelisted
- 19024: keyword check failed
- 99991663: token invalid or expired (re-run Step A)
- 230001: bot not in chat or no permission
Important
- Always escape special characters in JSON (quotes, backslashes, newlines)
- Use or heredoc to safely pass message content to curl if it contains special characters
printf '%s' - If required env vars are not set, tell user which ones to configure
- Keep messages concise — Feishu cards have display limits
- Token from Step A is valid for 2 hours; no need to refresh within a session
- App permissions required: (send messages),
im:message:send_as_bot(upload images and files)im:resource