Developing a Bot for Bitrix24 Task Automation
A manager creates a task but forgets to set a deadline — the task sits idle for a week. Another manager closes a deal but doesn't create a task for fulfillment — the client waits. A third scenario: every morning a supervisor manually collects task statuses from different projects. All of this is solved with a bot that works inside Bitrix24's chat and interacts with tasks, CRM, and notifications via REST API.
Bot Architecture
A bot in Bitrix24 is a server-side application registered via the imbot.register method. The portal sends events to the handler URL (webhook endpoint), the bot processes commands and responds via imbot.message.add. All logic runs on your server — Bitrix24 serves as the interface (chat) and data source (REST API).
Key components:
-
Bot registration —
imbot.registerspecifying EVENT_HANDLER (URL for receiving events), MESSAGE_ADD (URL for sending messages), BOT_ID. After registration, the bot appears in the chat list. - Command handler — a server endpoint that receives POST requests from Bitrix24 when a message is sent to the bot. Parses command text, executes logic, responds.
-
REST API calls — the bot works with tasks (
tasks.task.add,tasks.task.update,tasks.task.list), CRM (crm.deal.get,crm.lead.add), notifications (im.notify), users (user.get).
Automation Scenarios
Task Controller Bot
Runs on schedule (cron on the server side) and checks tasks via tasks.task.list with filters:
- Tasks without deadline (
DEADLINE= null) — sends a message to the responsible: "Task #123 has no deadline. Set a deadline or explain why". - Overdue tasks (
DEADLINE < now,STATUS!= 5) — notifies the supervisor and executor. - Tasks inactive for more than N days —
DATE_LAST_ACTIVITYis compared with current date. If a task is "stuck" — a ping in the chat.
The bot writes to the employee's personal chat or to the project group chat depending on settings. The message contains a link to the task, the responsible person's name, and the number of days overdue.
CRM Assistant Bot
A manager writes to the bot in chat: "Create a task for shipping on deal 4521". The bot:
- Calls
crm.deal.getwith ID 4521 — receives deal data. - Extracts contact, amount, products from the deal.
- Calls
tasks.task.add— creates a task with filled fields: title, description with deal data, responsible (from settings), deadline (current date + 2 business days). - Responds in chat: "Task #789 created, responsible — Ivanov A.S., deadline — Mar 15".
Parsing text commands is implemented via regular expressions or a set of fixed templates. For complex scenarios, we connect NLP processing, but in 90% of cases simple parsing is sufficient.
Report Collector Bot
A supervisor writes: "Status on project Alpha". The bot:
- Finds the group (project) by name via
sonet_group.getwith a filter. - Gets project tasks:
tasks.task.listwithGROUP_IDfilter. - Groups by status: new, in progress, completed, overdue.
- Compiles a summary and sends it to the chat.
The response format is a structured message with breakdown by category. The Bitrix24 REST API supports formatting: bold text, links, separators.
Event Processing (Webhook Handler)
The bot receives events via POST requests. Main event types:
-
ONIMBOTMESSAGEADD — user wrote to the bot. Payload contains
DIALOG_ID,MESSAGE_ID,FROM_USER_ID, message text. - ONIMBOTJOINCHAT — bot added to a group chat.
- ONIMBOTDELETE — bot removed from chat.
The handler must respond with HTTP 200 within 5 seconds — otherwise Bitrix24 considers the request failed. If command processing takes longer (external API request, heavy task query), we use asynchronous processing: receive event, put in queue, respond 200, process in background, send result via imbot.message.add.
Integration with External Services
The bot is not limited to Bitrix24 data. Typical external connections:
- Trackers and Git. Bot receives webhook from GitLab/GitHub on merge — finds a task in Bitrix24 by number from commit, changes status to "Completed".
- Monitoring. Zabbix sends alert → bot creates a task in the "Infrastructure" project and notifies the on-call person.
-
Calendar and HR. Bot checks absences via
calendar.event.getand redistributes tasks of an employee on sick leave.
Implementation Timeline
| Scale | Includes | Timeline |
|---|---|---|
| Simple bot | 1–2 commands, work with tasks or CRM, no external integrations | 3–5 days |
| Medium | 5–10 commands, integration with 1–2 external services, event handling | 1–2 weeks |
| Complex | Full-featured assistant with NLP, multiple integrations, admin panel | 3–4 weeks |
Technical Requirements
The bot server-side runs on your server or in the cloud. Requirements:
- HTTPS access — Bitrix24 sends events only to HTTPS endpoints.
- Response time — less than 5 seconds for POST requests. For heavy operations — queue (Redis, RabbitMQ).
-
Authorization — bot works with OAuth application rights. During registration via
imbot.register, scope is specified:imbot,task,crm,sonet_group, and other modules the bot accesses. - Logging — all incoming events and outgoing REST API calls are logged. Without logs, debugging the bot becomes guesswork.
What We Develop
- Server-side bot handler (Node.js, PHP, or Python — depends on your infrastructure)
- Bot registration in Bitrix24 via
imbot.register - Set of commands for your business processes
- Integration with external services via webhook or API
- Testing in dev environment, deployment to production
- Documentation for bot commands for employees







