Developing a Telegram bot with Bitrix24 integration

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

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:

  1. The bot saves the dialog history (last N messages) to Redis.
  2. Creates a request in the open line via imopenlines.crm.chat.getLink or directly by creating a chat via im.chat.add.
  3. Sends the history as the first message so the operator sees the context.
  4. 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.list by UF_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