Send messages using Feishu custom bot. For details, refer to Feishu Documentation.
String, Feishu custom bot signature key. If the bot has not enabled signature, this parameter can be ignored.String, message type, available values are text, post, interactive, default is text.String | Object, message content.
Required when msg_type is text or post.
Refer to format description below.Object, card message content. Required when msg_type is interactive. Refer to format description below.String, message content file path. When this value exists, it will read content from the file and override
content and card parameters. Refer to format description below.String, Base64 decoding suffix identifier. Default is _cnb_base64_decode. When a JSON field's key ends with this suffix and its value is true, the corresponding original field will undergo Base64 decoding.When msg_type is text, the message content format is:
{
"text": "New Update Notification"
}
If parsing fails, the content will be sent as is. It will be automatically assembled into the following format:
{
"text": "$content"
}
When msg_type is post, the message content format is:
{
"post": {
"zh_cn": {
"title": "Project Update Notification",
"content": [
[
{
"tag": "text",
"text": "Project has updates: "
},
{
"tag": "a",
"text": "Check here",
"href": "http://www.example.com/"
},
{
"tag": "at",
"user_id": "ou_18eac8********17ad4f02e8bbbb"
}
]
]
}
}
}
The card message content format is:
{
"elements": [
{
"tag": "div",
"text": {
"content": "**West Lake**, located at No.1 Longjing Road, West Lake District, Hangzhou.",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "More Scenic Spots Introduction :rose:",
"tag": "lark_md"
},
"url": "https://www.example.com",
"type": "default",
"value": {}
}
],
"tag": "action"
}
],
"header": {
"title": {
"content": "Today's Travel Recommendation",
"tag": "plain_text"
}
}
}
The filepath corresponding file content format is:
{
"content": {
"post": {
"zh_cn": {
"title": "Project Update Notification",
"content": [
[
{
"tag": "text",
"text": "Project has no updates: "
},
{
"tag": "a",
"text": "Check here",
"href": "http://www.example.com/"
}
],
[
{
"tag": "text",
"text": "Project has no updates: "
},
{
"tag": "a",
"text": "Check here",
"href": "http://www.example.com/"
}
]
]
}
}
},
"card": {
"elements": [
{
"tag": "div",
"text": {
"content": "**East Lake**, located at No.1 Longjing Road, West Lake District, Hangzhou.",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "More Scenic Spots Introduction :rose:",
"tag": "lark_md"
},
"url": "https://www.example.com",
"type": "default",
"value": {}
}
],
"tag": "action"
}
],
"header": {
"title": {
"content": "Today's Travel Recommendation",
"tag": "plain_text"
}
}
}
}
According to msg_type, either content or card content should exist.
To resolve formatting errors caused by complex characters (e.g., line breaks, quotes) in JSON/YAML, the plugin supports Base64 decoding of field values. This feature supports recursive processing (including nested objects). This functionality is typically required when environment variables are directly assigned to fields, meaning it cannot be applied when directly manipulating environment variables during the CNB build process.
Usage:
target_field_name + suffix (default suffix: _cnb_base64_decode).true.Example: Assume the content to be sent contains line breaks. The original JSON is as follows:
{
"content": "5Zi/5L2g5aW977yBCui/meaYr+S4gOS4quebuOWvueWkjeadguS4lOWFt+acieaNouihjOespu+8jOWIhumalOespuetieWQhOenjeeJueauiuespuWPt+eahOWGheWuuQpAICYgKiogXHQgXG4=",
"content_cnb_base64_decode": true
}
The plugin automatically decodes the content and removes the content_cnb_base64_decode field.
The robot address and signature key can be configured in a private repository and imported into environment variables through imports.
# env.yml
ROBOT: https://open.feishu.cn/open-apis/bot/v2/hook/xx
SIGN_SECRET: xxx
main:
pull_request:
- imports: https://xxx/env.yml
stages:
- name: send simple message
image: tencentcom/feishu-message
settings:
robot: $ROBOT
content: New Update Notification
- name: send message
image: tencentcom/feishu-message
settings:
robot: $ROBOT
content: |
{
"text": "New Update Notification"
}
main:
pull_request:
- imports: https://xxx/env.yml
stages:
- name: send message
image: tencentcom/feishu-message
settings:
robot: $ROBOT
msg_type: post
content: |
{
"post": {
"zh_cn": {
"title": "Project Update Notification",
"content": [
[{
"tag": "text",
"text": "Project has updates: "
}, {
"tag": "a",
"text": "Check here",
"href": "http://www.example.com/"
}, {
"tag": "at",
"user_id": "ou_18eac8********17ad4f02e8bbbb"
}]
]
}
}
}
main:
pull_request:
- imports: https://xxx/env.yml
stages:
- name: send message
image: tencentcom/feishu-message
settings:
robot: $ROBOT
msg_type: interactive
card: |
{
"elements": [
{
"tag": "div",
"text": {
"content": "**West Lake**, located at No.1 Longjing Road, West Lake District, Hangzhou, Zhejiang
Province, western part of Hangzhou city. The scenic area covers 49 square kilometers, with a water catchment area of 21.22
square kilometers and a lake area of 6.38 square kilometers.",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "More Scenic Spots Introduction :rose:",
"tag": "lark_md"
},
"url": "https://www.example.com",
"type": "default",
"value": {}
}
],
"tag": "action"
}
],
"header": {
"title": {
"content": "Today's Travel Recommendation",
"tag": "plain_text"
}
}
}