wildix-send-message

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Send Message

发送消息

Send a text message (with optional file attachments or as a reply) to an x-bees, collaboration 7, or x-hoppers channel — either as a bot or on behalf of a user.
代表机器人或用户向x-bees、collaboration 7或x-hoppers频道发送文本消息(可附带文件附件或作为回复)。

Peer Skills

关联技能

Before running, check if required peer skills are installed:
bash
Glob ~/.claude/skills/wildix-auth/SKILL.md
运行前,请检查是否已安装所需的关联技能:
bash
Glob ~/.claude/skills/wildix-auth/SKILL.md

If missing: npx skills add Wildix/agent-skills --s wildix-auth -y

若缺失:npx skills add Wildix/agent-skills --s wildix-auth -y


See [`peers.yaml`](peers.yaml) for full peer manifest.

完整的关联技能清单请查看[`peers.yaml`](peers.yaml)。

Choosing a Token

选择令牌

BOT_TOKEN in .env?
  YES → use bot mode (no auth needed)
  NO  → user wants to send as themselves?
          YES → get ID_TOKEN via wildix-auth skill
          NO  → ask: "Provide BOT_TOKEN or send as your user account?"
                  BOT_TOKEN provided → save to .env, use bot mode
                  user account       → get ID_TOKEN via wildix-auth skill

.env文件中是否存在BOT_TOKEN?
  是 → 使用机器人模式(无需认证)
  否 → 用户是否要以自身身份发送?
          是 → 通过wildix-auth技能获取ID_TOKEN
          否 → 询问:“请提供BOT_TOKEN,还是使用您的用户账户发送?”
                  提供BOT_TOKEN → 保存到.env,使用机器人模式
                  使用用户账户 → 通过wildix-auth技能获取ID_TOKEN

Mode 1: Simple text message

模式1:简单文本消息

Bot:
bash
bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"
User (pass ID_TOKEN via env):
bash
ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"

机器人模式:
bash
bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"
用户模式(通过环境变量传递ID_TOKEN):
bash
ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"

Mode 2: Reply to a message (quote)

模式2:回复消息(引用)

Pass
--reply-to <messageId>
— the server renders the quoted message in the UI automatically.
bash
undefined
传递
--reply-to <messageId>
—— 服务器会在UI中自动渲染被引用的消息。
bash
undefined

Bot:

机器人模式:

bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<replyText>"
--reply-to "<messageId>"
bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<replyText>"
--reply-to "<messageId>"

User (token via env):

用户模式(通过环境变量传递令牌):

ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<replyText>"
--reply-to "<messageId>"

The `messageId` is the 32-char ID from a previous message (available in chat history).

The script automatically fetches the original message to build the full `quote` object (API requires `messageId`, `channelId`, `createdAt`, `user`).

---
ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<replyText>"
--reply-to "<messageId>"

`messageId`是历史消息中的32位字符ID(可在聊天历史中找到)。

脚本会自动获取原始消息以构建完整的`quote`对象(API需要`messageId`、`channelId`、`createdAt`、`user`)。

---

Mode 3: Send with file attachments

模式3:发送带文件附件的消息

Step 1 — upload each file

步骤1 —— 上传每个文件

bash
undefined
bash
undefined

Bot:

机器人模式:

ATTACH1=$(bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/file.pdf") ATTACH2=$(bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/image.png")
ATTACH1=$(bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/file.pdf") ATTACH2=$(bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/image.png")

User (token via env):

用户模式(通过环境变量传递令牌):

ATTACH1=$(ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/file.pdf") ATTACH2=$(ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/image.png")

`upload-file.sh` outputs a `MessageAttachment` JSON string. It internally:
1. Requests a presigned S3 URL from the API
2. Uploads the file binary to S3
3. Fetches file metadata and returns it as JSON
ATTACH1=$(ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/file.pdf") ATTACH2=$(ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/image.png")

`upload-file.sh`会输出一个`MessageAttachment` JSON字符串。其内部流程:
1. 向API请求一个预签名的S3 URL
2. 将文件二进制数据上传到S3
3. 获取文件元数据并以JSON格式返回

Step 2 — send message with attachments

步骤2 —— 发送带附件的消息

bash
undefined
bash
undefined

Bot:

机器人模式:

bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"
--attach "$ATTACH1"
--attach "$ATTACH2"
bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"
--attach "$ATTACH1"
--attach "$ATTACH2"

User (token via env):

用户模式(通过环境变量传递令牌):

ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"
--attach "$ATTACH1"

---
ID_TOKEN="$ID_TOKEN" bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>"
--attach "$ATTACH1"

---

Mode 4: Reply with attachments

模式4:带附件的回复

Combine
--reply-to
and
--attach
:
bash
ATTACH=$(bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/file.pdf")

bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>" \
  --reply-to "<messageId>" \
  --attach "$ATTACH"

结合
--reply-to
--attach
参数:
bash
ATTACH=$(bash <BASE_DIR>/scripts/upload-file.sh "<channelId>" "/path/to/file.pdf")

bash <BASE_DIR>/scripts/send-message.sh "<channelId>" "<text>" \
  --reply-to "<messageId>" \
  --attach "$ATTACH"

API

API

OperationEndpoint
Send message
POST /v2/conversations/channels/{channelId}/messages
Request upload URL
POST /v2/conversations/channels/{channelId}/files
Upload binary
PUT <presignedUploadUrl>
(S3, no auth header)
Get file metadata
GET /v2/conversations/channels/{channelId}/files/{fileId}
Send message body fields:
  • text
    — message text (required unless attachments present)
  • quote.messageId
    — messageId to reply to
  • attachments
    — array of
    MessageAttachment
    objects from upload step

操作端点
发送消息
POST /v2/conversations/channels/{channelId}/messages
请求上传URL
POST /v2/conversations/channels/{channelId}/files
上传二进制数据
PUT <presignedUploadUrl>
(S3,无需认证头)
获取文件元数据
GET /v2/conversations/channels/{channelId}/files/{fileId}
发送消息请求体字段:
  • text
    —— 消息文本(除非有附件,否则为必填项)
  • quote.messageId
    —— 要回复的消息ID
  • attachments
    —— 来自上传步骤的
    MessageAttachment
    对象数组

.env format

.env格式

<BASE_DIR>/.env
:
BOT_TOKEN=wsk-v1-...

<BASE_DIR>/.env
BOT_TOKEN=wsk-v1-...

Common Mistakes

常见错误

ProblemFix
Using AccessToken instead of IdTokenAlways use IdToken (from wildix-auth) for user-mode sends
Passing raw file path to
--attach
First run
upload-file.sh
, pass its JSON output to
--attach
file
command not found
On macOS
file
is built-in; on minimal Linux:
apt install file
S3 upload 403Presigned URL expired — re-run
upload-file.sh
(URLs are short-lived)
问题解决方法
使用AccessToken而非IdToken用户模式发送时请始终使用IdToken(来自wildix-auth)
直接将原始文件路径传递给
--attach
先运行
upload-file.sh
,将其输出的JSON传递给
--attach
file
命令未找到
macOS系统中
file
是内置命令;精简版Linux系统请执行:
apt install file
S3上传返回403预签名URL已过期 —— 重新运行
upload-file.sh
(URL有效期较短)