integration ⏱️ 11 min

Integration of Bitrix24 with Telegram Bot for Automating Incoming Request Processing

Step-by-step guide to integrating a Telegram bot with Bitrix24 for automated registration of incoming requests. Includes cloud and on-premise scenarios, processing logic, and business process setup.

#=Telegram #bots #integration #CRM #requests #Bitrix24 #REST API #business processes

Integration of Bitrix24 with Telegram Bot for Automating Incoming Request Processing

Why Integrate Telegram with Bitrix24

Telegram serves as a widely used customer communication channel due to its accessibility and automation capabilities through bots. Integration with Bitrix24 centralizes request handling from Telegram and enables prompt responses by recording inquiries in the CRM and triggering internal processing mechanisms.

Typical integration tasks include:

  • Receiving messages via the Telegram bot
  • Creating deals or leads in the CRM based on message content
  • Notifying assigned managers
  • Initiating business processes or automation robots

Implementation Options: Cloud and On-Premise (Self-Hosted)

Cloud Integration

For Bitrix24 cloud accounts, integration is performed via the REST API. Telegram sends new messages using webhooks. To process these, an external server (e.g., based on PHP, Node.js, or Python) must be configured to receive updates.

Step-by-step process:

  1. Create a Telegram bot using BotFather
  2. Assign a webhook endpoint to the bot
  3. Handle incoming webhook messages on the server
  4. Call the crm.lead.add or crm.deal.add Bitrix24 REST method with the message data
  5. Optionally, use imbot.message.add to notify an internal Bitrix24 user

// Example for processing a request and creating a lead
$incomingMessage = json_decode(file_get_contents('php://input'), true);

$telegramUserId = $incomingMessage['message']['from']['id'];
$messageText = $incomingMessage['message']['text'];

$leadData = [
    'fields' => [
        'TITLE' => 'Request from Telegram',
        'NAME' => 'Telegram User ' . $telegramUserId,
        'COMMENTS' => $messageText,
        'STATUS_ID' => 'NEW'
    ]
];

// Call to Bitrix24 REST API via HTTP request (e.g., using curl or another HTTP client)

On-Premise Integration

In on-premise (self-hosted) Bitrix24 installations, a custom module can be built on the D7 platform. This module interacts with the Telegram API and integrates with the Bitrix core using internal classes and methods.

Frequently used techniques include:

  • Creating agents or scheduled tasks (cron jobs) to process incoming messages
  • Using event handlers to link messages with CRM entities
  • Registering custom REST endpoints directly within the system

Message Processing Logic and Routing

After receiving a message, appropriate handling logic must be defined. Common scenarios include:

  • If the message contains keywords (e.g., “buy,” “price,” “order”) — create a lead with a specific tag
  • If a particular product is mentioned — initiate a product selection business process
  • If a phone number is present — search for an existing contact

Additional routing is possible based on parameters such as geolocation, language, time of day, or message length.

Using Business Processes and Automation Robots

Once a lead or deal is created, standard Bitrix24 automation tools may be applied:

  • Business processes – verify contact information, assign tasks to managers, define SLA terms
  • Automation robots – respond automatically via Telegram, transition between stages, integrate with 1C

Implementation often involves branching templates with timers to monitor request processing deadlines.

Common Mistakes

  • Incorrect webhook handling (missing 200 OK response)
  • Sending incomplete data to Bitrix24 (e.g., missing name or phone number)
  • Rigid message parsing instead of using regular expressions or NLP techniques
  • Lack of logging or debugging tools for service failure cases
  • Not accounting for timeouts and rate limits in Telegram and Bitrix24 REST APIs

Configuration Checklist

  • Telegram bot is created
  • Webhook is properly configured and publicly accessible
  • Incoming messages are parsed
  • Entity creation in CRM is implemented via REST or D7
  • Duplicate message protection is in place
  • Logging and failure alerts are configured

FAQ

  1. Can multiple Telegram bots be connected? Yes. Each bot can have its own webhook and independent processing logic.
  2. How is a Telegram user identified in Bitrix24? Telegram user IDs are typically stored as external identifiers and linked to contacts or leads.
  3. Is it possible to respond to users via Telegram? Yes. Responses can be sent using the sendMessage method of the Telegram Bot API.
  4. Can data be collected through forms in Telegram? Yes. This is achievable using inline keyboard flows and sequential message handling.
  5. Can NLP be used for message processing? Yes. External text processing services may be integrated to support machine learning or keyword recognition.

Conclusion

Integrating a Telegram bot with Bitrix24 enables automation of incoming request capture and initial processing, tailored to specific business logic. The tools used depend on the type of Bitrix24 deployment: REST API for cloud environments and internal modules for on-premise versions. When designing such a system, it is important to consider integration bottlenecks, enable logging, and ensure external services are fault-tolerant.


Want to explore Telegram integration?

If you plan to implement similar functionality, a short consultation may help estimate effort and outline technical requirements. Typically, a few points are clarified before development starts:

  • Which Bitrix24 version is in use – cloud or on-premise
  • Whether there is an available server and what technology stack it runs
  • What entities and business logic need to be integrated
Категория: integration
Время чтения: 11 min
Полезная статья?
Сохраните в закладки, чтобы не потерять
Ctrl + D