forward_message
Forward a specific message to a different chat or user by specifying the target ID and its type (chat, open, union, user, or email).
Instructions
[Official API] Forward a message to another chat or user. receive_id may be a group chat_id (oc_xxx), an open_id (ou_xxx), a union_id, a user_id, or an email — set receive_id_type to match (default: chat_id).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message_id | Yes | Message ID to forward (om_xxx) | |
| receive_id | Yes | Target chat_id (oc_xxx), open_id (ou_xxx), union_id, user_id, or email — set receive_id_type to match. | |
| receive_id_type | No | Format of receive_id (default: chat_id). Set to "open_id" when forwarding to a user via their open_id. | chat_id |
Implementation Reference
- src/tools/messaging-bot.js:114-127 (handler)Handler for forward_message: auto-detects receive_id_type based on ID prefix (ou_→open_id, on_→union_id, @→email, else chat_id), then calls ctx.getOfficialClient().forwardMessage() to forward the message.
async forward_message(args, ctx) { // Auto-detect receive_id_type when not provided so callers can pass an open_id // (ou_xxx) without having to set the type field — matches what // send_to_user/send_to_group already do for chat resolution. let receiveIdType = args.receive_id_type; if (!receiveIdType) { const id = args.receive_id || ''; if (id.startsWith('ou_')) receiveIdType = 'open_id'; else if (id.startsWith('on_')) receiveIdType = 'union_id'; else if (id.includes('@')) receiveIdType = 'email'; else receiveIdType = 'chat_id'; } return text(`Forwarded: ${(await ctx.getOfficialClient().forwardMessage(args.message_id, args.receive_id, receiveIdType)).messageId}`); }, - src/tools/messaging-bot.js:33-45 (schema)Schema definition for the forward_message tool with input validation (message_id, receive_id required; receive_id_type optional with enum).
{ name: 'forward_message', description: '[Official API] Forward a message to another chat or user. `receive_id` may be a group chat_id (oc_xxx), an open_id (ou_xxx), a union_id, a user_id, or an email — set `receive_id_type` to match (default: chat_id).', inputSchema: { type: 'object', properties: { message_id: { type: 'string', description: 'Message ID to forward (om_xxx)' }, receive_id: { type: 'string', description: 'Target chat_id (oc_xxx), open_id (ou_xxx), union_id, user_id, or email — set receive_id_type to match.' }, receive_id_type: { type: 'string', enum: ['chat_id', 'open_id', 'union_id', 'user_id', 'email'], description: 'Format of receive_id (default: chat_id). Set to "open_id" when forwarding to a user via their open_id.', default: 'chat_id' }, }, required: ['message_id', 'receive_id'], }, }, - src/server.js:56-57 (registration)Tool registration: messaging-bot module is loaded in TOOL_MODULES (line 47), its schemas are flattened into the tools list, and handlers (including forward_message) are indexed by name for dispatch via CallToolRequestSchema.
const TOOLS = TOOL_MODULES.flatMap((m) => m.schemas); const HANDLERS = Object.fromEntries(TOOL_MODULES.flatMap((m) => Object.entries(m.handlers))); - src/clients/official/im.js:144-154 (helper)Low-level Feishu API wrapper: calls im.message.forward SDK method with message_id path, receive_id data, and receive_id_type param. Returns the new messageId.
async forwardMessage(messageId, receiverId, receiveIdType = 'chat_id') { const res = await this._safeSDKCall( () => this.client.im.message.forward({ path: { message_id: messageId }, data: { receive_id: receiverId }, params: { receive_id_type: receiveIdType }, }), 'forwardMessage' ); return { messageId: res.data.message_id }; },