b24_read_automations
Reads automation rules by stage, listing robots and triggers with their conditions and actions.
Instructions
Lee reglas de automatización (robots y triggers) por etapa con condiciones y acciones.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| webhook_url | No | URL del webhook (opcional si está configurado por defecto) | |
| entity_type_id | No | ID del tipo de entidad (opcional) |
Implementation Reference
- src/tools/read-automations.js:11-26 (handler)Main handler function that creates a Bitrix24 client, calls reader.readAutomations(), and returns the automation rules grouped by stage.
export async function readAutomations({ webhook_url, entity_type_id }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const reader = new Bitrix24Reader(client); const automations = await reader.readAutomations(entity_type_id); const totalRules = Object.values(automations).reduce((acc, rules) => acc + rules.length, 0); return { portal: client.portal, automations, stages_with_automations: Object.keys(automations).length, total_rules: totalRules, summary: `${totalRules} reglas de automatización en ${Object.keys(automations).length} etapas`, note: 'Las automatizaciones referencian usuarios por ID. Usar b24_read_users y b24_save_user_mapping antes de aplicar en otra instancia.', }; } - src/tools/read-automations.js:6-9 (schema)Zod schema defining optional webhook_url and entity_type_id parameters for the tool.
export const readAutomationsSchema = z.object({ webhook_url: z.string().url().optional().describe('URL del webhook (opcional si está configurado por defecto)'), entity_type_id: z.number().int().optional().describe('ID del tipo de entidad (opcional)'), }); - src/bitrix24/reader.js:86-101 (helper)Reader method that fetches automation rules via 'crm.automation.rule.list' API, grouping them by ENTITY_TYPE_ID:STAGE_ID.
async readAutomations(entityTypeId = null) { const automations = {}; try { const rules = await fetchAllPages(this.client, 'crm.automation.rule.list', { filter: entityTypeId ? { ENTITY_TYPE_ID: entityTypeId } : {}, }); for (const rule of rules) { const key = `${rule.ENTITY_TYPE_ID}:${rule.STAGE_ID}`; if (!automations[key]) automations[key] = []; automations[key].push(rule); } } catch { // bizproc scope may not be available } return automations; } - index.js:24-24 (registration)Import of readAutomationsSchema and readAutomations from the tool module.
import { readAutomationsSchema, readAutomations } from './src/tools/read-automations.js'; - index.js:154-156 (registration)Registration of 'b24_read_automations' tool on the MCP server with its schema and handler.
server.tool('b24_read_automations', 'Lee reglas de automatización (robots y triggers) por etapa con condiciones y acciones.', readAutomationsSchema.shape, wrap(readAutomations));