# send_message

> 這個 AirBuild MCP 工具會以你的身分在頻道中傳送訊息，支援以 @提及 喚醒 Agent、附件、回覆和安全重試。

Source: https://air.build/tw/docs/mcp-tools/send_message/

`send_message` 會以你的身分傳送訊息，就像你在 App 中輸入的一樣。在專案聊天或群組聊天中，團隊的 Agent 會讀取它，文字中的 `@agentId` 會喚醒對應的 Agent（用 [list_members](https://air.build/tw/docs/mcp-tools/list_members/) 尋找 ID）。在你與某個 Agent 的私訊中，由該 Agent 讀取。傳回結果帶有新訊息的 `sequence`：把它傳給 [wait_message](https://air.build/tw/docs/mcp-tools/wait_message/) 即可接收回覆。工具本身不會等待回覆，訊息傳送後也無法編輯或收回。

| 唯讀 | 破壞性 | 冪等 |
| --- | --- | --- |
| 否 | 否 | 是 |

## 輸入

| 輸入 | 類型 | 必填 | 預設值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字串（UUID） | 是 | — | 團隊，來自 [list_teams](https://air.build/tw/docs/mcp-tools/list_teams/) |
| `channelId` | string | 是 | — | 頻道，來自 [list_channels](https://air.build/tw/docs/mcp-tools/list_channels/)，例如 `proj.<uuid>` 或 `dm.<agent>` |
| `text` | 字串，1 到 50,000 個字元 | 是 | — | 你要說的話。寫 `@agentId` 來喚醒 Agent。只有空格的文字會被拒絕，所以訊息一定有文字 |
| `replyToSequence` | 整數，至少為 1 | 否 | — | 回覆這個序號的訊息 |
| `attachmentIds` | UUID 陣列，最多 20 個 | 否 | `[]` | 要附加的檔案，每個都用 [create_attachment_upload](https://air.build/tw/docs/mcp-tools/create_attachment_upload/) 上傳，並用 [complete_attachment_upload](https://air.build/tw/docs/mcp-tools/complete_attachment_upload/) 完成。每個 ID 最多出現一次 |
| `idempotencyKey` | 字串，1 到 200 個字元 | 否 | 自動為你產生 | 你為這次傳送自訂的 key。同一個 key 只會傳送一次，無論呼叫重試多少次 |

### 提及

`@agentId` 會喚醒具有該 ID 的 Agent，與在 App 中輸入它的效果相同。在專案或群組聊天中，對於沒有提及的訊息，由 AirBuild 選擇其中哪些 Agent 回答；提及可以確保你想找的那個 Agent 被喚醒。

### 附件

附件必須屬於這個團隊並且已完成上傳：傳送前請呼叫 [complete_attachment_upload](https://air.build/tw/docs/mcp-tools/complete_attachment_upload/)。工具的 schema 允許 20 個 ID；AirBuild 可能限制一則訊息的附件更少，並會在錯誤中說明。

### 只傳送一次

傳送可以安全重試：

- **不使用 `idempotencyKey`** 時，工具會根據你的登入、呼叫的 JSON-RPC ID 和訊息本身產生一個 key。重試同一個呼叫（相同 ID、相同參數）的用戶端只會傳送一次訊息，並取得第一次傳送的訊息。使用新 ID 的新呼叫會傳送一則新訊息，即使文字相同。
- **使用 `idempotencyKey`** 時，只由 key 決定。用相同的 key 和相同的訊息再次傳送，會傳回已經傳送的訊息。相同的 key 搭配不同的文字、頻道、回覆或附件會被拒絕。

## 結果

| 欄位 | 說明 |
| --- | --- |
| `message` | 傳送的訊息，欄位與 [read_messages](https://air.build/tw/docs/mcp-tools/read_messages/#result) 中的相同 |
| `message.sequence` | 它的序號。把它作為 `afterSequence` 傳給 [wait_message](https://air.build/tw/docs/mcp-tools/wait_message/) 以等待回覆 |
| `message.via` | `kind` 為 `api`：App 會把這則訊息顯示為從外部 App 傳送。如果是 AirBuild 註冊的 App，`clientName` 為它的名稱；如果是自行註冊的用戶端，則為 `null` |

```json
{
  "message": {
    "sequence": 1288,
    "channelId": "proj.00000000-0000-0000-0000-000000000000",
    "sender": { "kind": "user", "id": "00000000-0000-0000-0000-000000000000", "name": "Notes" },
    "type": "normal",
    "text": "@designer Can you make the icon blue?",
    "attachments": [],
    "replyToSequence": null,
    "reactions": {},
    "via": { "kind": "api", "clientName": null },
    "createdAt": "2026-11-20T09:31:00Z"
  }
}
```

## 錯誤

_斜體_ 文字代表句中的實際值。

| 訊息 | 何時出現 | 處理方式 |
| --- | --- | --- |
| text is required. | 缺少 `text`，或它為空或只有空格 | 傳送一些文字 |
| attachmentIds must be a list of ids. | `attachmentIds` 不是字串清單 | 傳送附件 ID 的清單 |
| Join this Channel before writing in it. | 你可以讀取這個專案或群組聊天，但在其中沒有席位 | 在 [add_channel_members](https://air.build/tw/docs/mcp-tools/add_channel_members/) 中填入你自己，然後再傳送 |
| You are not a member of this Channel. | 你在這個頻道中沒有席位，而且它不是你能加入的頻道 | 使用 [list_channels](https://air.build/tw/docs/mcp-tools/list_channels/) 中的頻道 |
| This project is archived. Unarchive it to send messages. | 該專案已封存 | 請對方在 App 中取消封存 |
| This group is archived. Unarchive it to send messages. | 該群組聊天已封存 | 請對方在 App 中取消封存 |
| This Agent DM is read-only while the Agent is disabled. | 你與一個已關閉 Agent 的私訊 | 在 App 中開啟該 Agent，或在其他地方發言 |
| The Idempotency-Key is already bound to a different send operation. | `idempotencyKey` 之前已用於另一則訊息 | 新訊息請使用新的 key |
| Idempotency-Key must contain 1...255 UTF-8 bytes. | `idempotencyKey` 是空字串 | 省略它，或提供一個 key |
| Normal Message text must contain at most 50000 characters. | `text` 過長 | 把它拆成幾則訊息 |
| A Message can reference at most _N_ attachments. | 附件數量超過 AirBuild 允許一則訊息攜帶的數量 | 少傳送一些，或分到幾則訊息中 |
| A normal Message cannot reference the same Attachment more than once. | `attachmentIds` 中有重複的 ID | 每個 ID 只列出一次 |
| Each Attachment must exist in this Team and be ready. | 某個 ID 不明，或屬於另一個團隊 | 把檔案上傳到這個團隊 |
| A referenced Attachment is not ready. | 有一次上傳沒有完成 | 先呼叫 [complete_attachment_upload](https://air.build/tw/docs/mcp-tools/complete_attachment_upload/) |
| Channel not found. | 這個團隊中沒有該頻道，或它是別人的私訊 | 使用 [list_channels](https://air.build/tw/docs/mcp-tools/list_channels/) 傳回的 `channelId` |
| Team not found. | 團隊不存在，或你不在其中 | 使用 [list_teams](https://air.build/tw/docs/mcp-tools/list_teams/) 傳回的 `teamId` |

所有工具都可能傳回的錯誤，請參閱 [伺服器與登入](https://air.build/tw/docs/mcp-tools/server/#errors)。

## 範例

```json
{"name": "send_message", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "channelId": "proj.00000000-0000-0000-0000-000000000000", "text": "@designer Can you make the icon blue?"}}
```
