b24_crm_timeline_add
Add comments or activities to the timeline of any CRM record, including deals, contacts, companies, and leads, to track updates and interactions.
Instructions
Agrega un comentario o actividad a la línea de tiempo de un registro CRM.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity | Yes | Tipo de entidad CRM: deal, contact, company, lead | |
| entity_id | Yes | ID del registro CRM | |
| comment | Yes | Texto del comentario a agregar en la línea de tiempo | |
| webhook_url | No |
Implementation Reference
- src/tools/crm.js:152-160 (handler)Handler function for b24_crm_timeline_add – calls Bitrix24 REST method crm.timeline.comment.add to add a timeline comment to a CRM entity.
export async function timelineAdd({ entity, entity_id, comment, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const entityMap = { deal: 'CRM_DEAL', contact: 'CRM_CONTACT', company: 'CRM_COMPANY', lead: 'CRM_LEAD' }; const entityCode = entityMap[entity?.toLowerCase()] ?? entity.toUpperCase(); const res = await client.call('crm.timeline.comment.add', { fields: { ENTITY_ID: entity_id, ENTITY_TYPE: entityCode, COMMENT: comment }, }); return { portal: client.portal, entity, entity_id, comment_id: res.result, success: true }; } - src/tools/crm.js:145-150 (schema)Zod schema for timelineAdd input validation: entity, entity_id, comment, and optional webhook_url.
export const timelineAddSchema = z.object({ entity: z.string().describe('Tipo de entidad CRM: deal, contact, company, lead'), entity_id: z.union([z.string(), z.number()]).describe('ID del registro CRM'), comment: z.string().describe('Texto del comentario a agregar en la línea de tiempo'), webhook_url: z.string().url().optional(), }); - index.js:133-135 (registration)Registers the tool 'b24_crm_timeline_add' with the MCP server, linking schema and handler.
server.tool('b24_crm_timeline_add', 'Agrega un comentario o actividad a la línea de tiempo de un registro CRM.', timelineAddSchema.shape, wrap(timelineAdd)); - src/utils/resolve-webhook.js:1-10 (helper)Helper that resolves the webhook URL from 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; } - index.js:78-90 (helper)Wrapper that converts handler return values into MCP content responses with error handling.
function wrap(fn) { return async (params) => { try { const result = await fn(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (err) { const msg = err.response?.data ? `${err.message}\nBitrix24: ${JSON.stringify(err.response.data)}` : err.message; return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true }; } }; }