b24_chat_send
Send a message to a private or group chat in Bitrix24 IM. Specify the chat ID and message content.
Instructions
Envía un mensaje a un chat privado o grupal en el IM de Bitrix24.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dialog_id | Yes | ID del chat. Para mensaje privado: "userId_NUMERO" o ID numérico del usuario. Para chat grupal: ID del chat | |
| message | Yes | Texto del mensaje | |
| webhook_url | No |
Implementation Reference
- src/tools/feed-notifications.js:86-93 (handler)The actual handler function for b24_chat_send. It calls Bitrix24 API 'im.message.add' with dialog_id and message, then returns portal, message_id, and success.
export async function chatSend({ dialog_id, message, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const res = await client.call('im.message.add', { DIALOG_ID: dialog_id, MESSAGE: message, }); return { portal: client.portal, message_id: res.result, success: true }; } - Zod schema for b24_chat_send input: dialog_id (string or number), message (string), and optional webhook_url.
export const chatSendSchema = z.object({ dialog_id: z.union([z.string(), z.number()]).describe( 'ID del chat. Para mensaje privado: "userId_NUMERO" o ID numérico del usuario. ' + 'Para chat grupal: ID del chat' ), message: z.string().describe('Texto del mensaje'), webhook_url: z.string().url().optional(), }); - index.js:239-241 (registration)Registration of the 'b24_chat_send' tool on the MCP server, binding the schema and handler.
server.tool('b24_chat_send', 'Envía un mensaje a un chat privado o grupal en el IM de Bitrix24.', chatSendSchema.shape, wrap(chatSend)); - index.js:55-63 (registration)Import of chatSendSchema and chatSend from the feed-notifications module into the main server file.
import { feedPostSchema, feedPost, notifySendSchema, notifySend, groupsListSchema, groupsList, chatSendSchema, chatSend, bizprocListSchema, bizprocList, bizprocStartSchema, bizprocStart, telephonyCallsSchema, telephonyCalls, } from './src/tools/feed-notifications.js'; - src/utils/resolve-webhook.js:1-11 (helper)Utility function resolveWebhook used by chatSend to determine the webhook URL from the parameter or environment variable.
export function resolveWebhook(webhookParam) { const url = webhookParam || process.env.B24_DEFAULT_WEBHOOK; if (!url) { throw new Error( 'No se especificó webhook_url y no hay B24_DEFAULT_WEBHOOK configurado. ' + 'Indicá el webhook en el parámetro webhook_url o configuralo en el servidor MCP.' ); } return url; }