How to Connect a Telegram Bot to amoCRM or Bitrix24
Practice4 minInnovialabs editorial team
In short
If managers need to chat with customers from inside the CRM, connect the bot via the built-in Telegram channel in amoCRM or Bitrix24 Open Channels; if you need structured leads from a bot scenario, send them via the API after looking up the contact by phone or Telegram ID.
The short answer
There are two paths, and they solve different problems:
- Native connector. In amoCRM the bot is connected as a chat channel; in Bitrix24 through Open Channels. Customer messages land in the CRM and managers reply from the record. Good when the bot is mainly a communication channel.
- API integration. Your bot walks the customer through a scenario, collects the answers and creates the contact and deal or lead with the right fields itself. Good when the bot qualifies leads.
They are often combined: the bot scenario creates a deal via the API, and further conversation goes through the connector.
Comparing the approaches
| Connector | API | |
|---|---|---|
| Setup | Configured in the CRM interface | Needs code and a server |
| Chat inside the CRM | Yes, out of the box | Only if you build it |
| Custom fields and logic | Minimal | Full control |
| Scenario-driven bot | Limited | Yes |
| Duplicate control | CRM rules | Your logic |
Important: usually you cannot attach both a connector and your own update handler to the same bot. Telegram delivers updates to a single receiver, either a webhook or long polling. If you need both a scenario and chat in the CRM, plan the architecture upfront: for example, your server receives every update and forwards messages to the CRM through its chat API.
Sending a lead via the API
amoCRM. Use REST API v4. For leads, POST /api/v4/leads/complex is convenient: one request creates a deal with a contact and tags. Authorization is via an OAuth integration or a long-lived token.
[
{
"name": "Telegram lead",
"_embedded": {
"contacts": [
{
"first_name": "Aziz",
"custom_fields_values": [
{
"field_code": "PHONE",
"values": [{ "value": "+998901234567", "enum_code": "WORK" }]
}
]
}
],
"tags": [{ "name": "telegram" }]
}
}
]
Bitrix24. The easiest start is an inbound webhook with CRM permissions. A lead is created with crm.lead.add, a deal with a contact via crm.contact.add and crm.deal.add. To find existing customers, use crm.duplicate.findbycomm, which searches by phone or email.
Field mapping
Before writing code, make a table: what the bot asks and where it goes in the CRM.
- Name: from the user's answer, not only the Telegram profile, which often holds a nickname.
- Phone: via the "Share contact" button, in a single format such as
+998.... - Telegram ID and username: in dedicated custom contact fields. The ID lets you find the customer even without a phone.
- Answers: into deal fields (budget, service, timeline), not as one blob in a note. Otherwise you cannot filter by them.
- Source and UTM: from the deep link
startparameter (t.me/bot?start=ads_spring). Save it on first entry and pass it to the deal. - Pipeline and stage: put bot leads into a dedicated stage or pipeline so managers see them right away.
Custom field IDs in amoCRM and field codes in Bitrix24 differ per account. Keep them in config, not in code.
Avoiding duplicates
- Look up the contact before creating one: by Telegram ID in your database, then by phone in the CRM.
- If found, attach the new deal to the existing contact. If the customer already has an open deal, adding a note or task is usually better than a new deal.
- Store the mapping
telegram_id → contact_id, deal_idon your side. It is faster than searching the CRM every time. - Make submission idempotent: a second tap on "Submit" or a retry after a timeout must not create a second deal. A request status in your database helps.
- Normalize phone numbers:
90 123 45 67and+998901234567are different strings to a CRM.
Reliability
- Send data to the CRM through a queue: if the API is down or you hit the rate limit, the lead is not lost and goes out later.
- Log CRM responses with the IDs of created entities.
- Mirror important leads to the managers' work chat in case the integration fails.
- Refresh tokens ahead of time: amoCRM OAuth tokens have a limited lifetime.