Telegram Bot Development with Bitrix24 Integration
A Telegram bot connected to Bitrix24 via an open line is not the same as a Telegram bot with direct CRM integration. In the first case, client messages simply go into the operator queue. In the second — the bot independently handles requests, creates deals, checks statuses, and only passes unresolved issues to an operator.
Two Integration Approaches
Option 1: Via Bitrix24 Open Lines. The Telegram bot is connected under "Contact Center → Open Lines → Connect Channels → Telegram." All Telegram messages enter the operator queue. Simple to set up, but here the bot is just a relay.
Option 2: Standalone Telegram bot with Bitrix24 integration. The bot is deployed on a separate server, receives messages via the Telegram Bot API (webhook or long polling), handles scenarios itself, and interacts with Bitrix24 via the REST API. Full control over the logic.
Most real tasks require the second approach — when automation is needed, not just message forwarding.
Architecture of a Standalone Bot
Client in Telegram
↓
Telegram Bot API (webhook)
↓
Bot server (Python aiogram / Node.js telegraf)
↓ ↓ ↓
Bot Bitrix24 REST API External services
logic (crm.*, im.*, tasks.*) (1C, warehouse, etc.)
The server receives an update from Telegram, determines the user's intent (FSM or NLP), performs the required actions in Bitrix24, and returns the response to Telegram.
Key Integration Points with Bitrix24
Client identification. On first contact, the bot requests a phone number via KeyboardButton(request_contact=True) in Telegram. The received number is used to search for a contact in CRM: crm.contact.list filtered by PHONE = '+...'. If found — links telegram_id to UF_CRM_TELEGRAM_ID of the contact. If not — creates a new contact.
Creating leads and deals. Every new inquiry via Telegram creates a lead: crm.lead.add with SOURCE_ID = 'MESSENGER' and field UTM_SOURCE = 'telegram'. All dialog messages are written as a lead comment via crm.timeline.comment.add.
Order status. The bot receives an order number → queries crm.deal.list by the custom field UF_ORDER_NUMBER → returns the current stage and expected date. The client gets a response in 2–3 seconds without an operator.
Service booking. The bot displays available slots from Bitrix24 Scheduling (the calendar module) via calendar.accessibility.get → the client selects a time → a meeting is created via calendar.event.add linked to the CRM contact.
Transferring to Bitrix24 Chat for an Operator
When the bot cannot handle a request, it transfers to an operator. Correct implementation:
- The bot saves the dialog history (last N messages) to Redis.
- Creates a request in the open line via
imopenlines.crm.chat.getLinkor directly by creating a chat viaim.chat.add. - Sends the history as the first message so the operator sees the context.
- The client continues the conversation in Telegram; the operator replies from Bitrix24.
Case: Bot for an Auto Service Chain
Task: 12 locations, clients want to book service appointments via Telegram, check vehicle readiness, and receive a receipt.
Bot scenarios:
- Book service → choose location (inline buttons) → choose service → choose date/time from Bitrix24 calendar → confirmation → SMS reminder one day before.
- Repair status → enter vehicle number → query
crm.deal.listbyUF_CAR_NUMBER→ current stage from deal stage. - Vehicle ready → automatic Telegram notification when stage changes to "Ready for pickup" (trigger via
crm.deal.onUpdate→ webhook to bot server →bot.send_message).
Tech stack: Python + aiogram 3 + Redis (FSM states) + PostgreSQL (logging) + Bitrix24 REST.
Issue: Telegram limits sending frequency — no more than 30 messages per second to different chats. For bulk notifications (all appointments for tomorrow) a queue with delays is required.
| Component | Effort |
|---|---|
| Basic bot + webhook | 8–16 h |
| Client identification in CRM | 8–16 h |
| FSM scenarios (booking, status) | 16–32 h |
| Bitrix24 calendar integration | 8–16 h |
| Outbound notifications + queue | 8–16 h |
| Deployment, SSL, monitoring | 4–8 h |







