Skip to content
← All articles
9 min read

Telegram bot CRM integration: how to capture leads and pass them to amoCRM or Bitrix24

A Telegram bot that captures leads should do five things: collect a few fields in a short dialogue, save the lead in its own database first, check the CRM for an existing contact, create the deal with a responsible manager, and retry if the CRM is down. Skip any of the five and leads get lost or doubled. Below is the scheme step by step.

What does the scheme look like from message to CRM deal?

Keep the bot and the CRM loosely coupled. The bot is a front door: it talks to the person and produces a clean record. The CRM is where managers work. Between them sits a small service with its own database. That service is the point of the whole design.

The flow has seven steps, and each one is a place where leads are usually lost:

  • The person writes to the bot or opens it from an ad link. The bot reads the start parameter and keeps the source.
  • The bot asks for a few fields and validates them (next section). Dialogue state lives in storage, not in memory: see how a bot keeps conversation state.
  • The service writes the lead to its own table with a unique key and the status "new". Only now does the bot tell the person "received".
  • A background worker takes the lead from the table, looks for an existing contact in the CRM and decides: attach to it or create a new one.
  • The worker creates the lead or deal, sets the responsible manager, writes the source and the dialogue summary.
  • The service stores the CRM entity id on the lead and marks it "delivered". If the CRM refused or was unreachable, it keeps the status and retries later.
  • The manager gets a notification with a link to the card.

Which fields should a Telegram lead bot collect?

Fewer questions, more completed dialogues. Ask only what a manager needs to make the first call or message, and let everything else come from Telegram itself and from the conversation.

From Telegram you get the user id, the first name and, if the person has one, the username. The user id is the stable identifier: a username can change or be missing. A phone number is not given automatically. The bot can show a button that asks the person to share their own contact, and the Telegram Bot API then delivers a contact object with a phone number and a first name. The person confirms the sharing, which also helps with consent. Offer typing a number as a fallback, and validate the format before you accept it.

Ask for the task in the person's own words, in one free-text question. This is the most useful field for a manager and the hardest one to replace with buttons.

  • Required: how to address the person, a way to reach them (Telegram id always, phone if the manager calls), and the task in one or two sentences.
  • Often useful: the product or service picked from buttons, the city or time zone if it affects the call, a convenient time to contact.
  • Collected silently: Telegram user id, username, the start parameter (campaign or page), date and time, language.
  • Do not ask what the manager will ask on the call anyway, or sensitive data the task does not need.
  • For ad campaigns map the source into the CRM fields meant for it. Bitrix24 lead has UTM fields (UTM_SOURCE, UTM_MEDIUM, UTM_CAMPAIGN and others) according to its documentation; in amoCRM use a custom field for the source.

How do you avoid duplicate contacts in the CRM?

Duplicates come from two places: the same person writes to the bot twice, and the bot creates a new contact for a person the CRM already knows from a call or a website form. Both are fixable, but the CRM will not always do it for you.

In Bitrix24 the REST method crm.duplicate.findbycomm takes a type (PHONE or EMAIL) and a list of values, up to 20, and returns the ids of leads, contacts and companies that share them. Phone matching ignores extension numbers. That is enough for the worker: search by the phone, and if a contact is found, attach the new lead or deal to it instead of creating another.

In amoCRM the complex lead method (POST /api/v4/leads/complex) creates a lead together with a contact and a company, up to 50 leads per request. According to the documentation, duplicate control can check the added data if it is enabled for the integration, and the response carries a merged flag. Treat that as a safety net, not as the plan: check on the CRM side what your account's duplicate control actually matches, and test it with real phone formats.

Normalize before you search. Store the phone as digits with the country code, compare in that format and keep the raw text separately.

  • One lead per Telegram user and open request: if the same user writes again while a lead is open, add a comment to the existing lead.
  • Search the CRM by normalized phone, then by email if you collected one. Never match by name alone.
  • If several contacts match, do not guess. Attach to the most recently active one and flag the lead for a manager to merge.
  • A person without a phone (only a Telegram id) still needs a stable key: save the user id in a custom field and search by it next time.

How do you assign a responsible manager?

A lead without an owner is a lead nobody answers. Decide the rule before you write code, and keep it simple enough to explain in one sentence.

In Bitrix24 the lead has the ASSIGNED_BY_ID field, the responsible user. In amoCRM the entity has a responsible user id as well. Both are plain ids, so the rule lives in your service: the CRM only receives the result.

  • Fixed owner: everything goes to one person. Right for a small team and a first launch.
  • Round robin: take the next manager from a list, skipping those marked absent. Keep the pointer in the database, not in memory.
  • By attribute: product, city or language selects the group or person.
  • Existing client: if the contact already has a responsible manager, keep the same one. People dislike explaining themselves twice.
  • Fallback: if the chosen manager is inactive or deleted in the CRM, assign to a default owner and mark the lead. A failed assignment must not block delivery.

How should the manager be notified?

CRMs have their own notifications, and a manager who lives in the CRM may need nothing more. In practice many sales people watch Telegram all day, so a short alert there shortens the first response time.

Send the alert from your service after the CRM confirms creation, not before. That way the message can include a link to the card, and no one chases a lead that does not exist yet. Keep it short: name, task, contact, source, link. An optional "Taken" button shows who reacted.

If the manager does not react within the time you set, send a reminder or pass the lead to someone else. This is a rule in your service, and it is the part ready-made connectors rarely do well.

What happens when the CRM is down? Retries, queue and idempotency

The CRM will sometimes fail or throttle you. amoCRM, for example, documents a limit of 7 requests per second per integration and 50 per account, returns HTTP 429 when you exceed it, and may block the account with 403 if violations repeat. A bot that sends a request inline and shows "sorry, error" will lose leads exactly when traffic is highest.

The fix is the order of steps from the first section: save first, deliver later. The lead is in your database with the status "new", the person has been told "received", and a worker delivers it. If delivery fails, the worker retries with growing pauses and gives up into a visible "failed" status that someone is alerted about. A small Postgres table used as a queue is often enough; see background jobs and queues in Go for the mechanics.

Retries create the opposite danger: the CRM created the deal, but the response was lost, and the retry creates a second one. This is the classic case for idempotency, covered in detail in API idempotency and retries. For this scheme the practical rules are short:

  • Every lead has your own unique id from the first save. Store the CRM entity id the moment the CRM returns it.
  • Before retrying a request whose outcome is unknown, look for the entity first: by your id if the CRM has a custom field for it, otherwise by phone and creation time.
  • Retry on timeouts, 429 and 5xx with increasing delays. Do not retry on validation errors: they will fail again, so mark the lead and alert a human.
  • Do not acknowledge Telegram webhooks late. If your handler returns a non-2xx status Telegram repeats the request a limited number of times, so the bot's handler must be idempotent too: remember processed update ids. Check webhook or long polling for the choice.
  • Alert on a growing queue and on any lead older than a threshold in "new" or "failed". Silence is the failure mode.

Consent for personal data: what to do inside the bot

A lead bot collects a name, a phone number and a message: personal data. Where consent is needed depends on your country and your legal basis, so agree the wording with your lawyer. The engineering side is the same either way: ask clearly, record it, and be able to prove it.

Show the consent text and a link to the privacy policy before the bot asks for contacts, and make agreeing a deliberate action, such as a button. Save the fact with the date, the policy version and the Telegram user id next to the lead. Do not pre-tick anything.

Keep a way to delete a person's data on request, including the CRM copy, and do not write it into general application logs.

When a form or no-code integration is enough

Not every business needs a custom service. A bot that asks three questions and creates a deal can be built from ready-made parts, and for a first test that is often the right move.

Ready connectors and no-code tools work when volume is low, the rule is "all leads to one person", and losing an occasional lead is cheap. Both CRMs also have their own ways to take messenger chats or website forms. See also n8n or custom code for where the limit lies.

A custom service starts to pay off when you need a rule your tool cannot express (round robin with absences, attaching to the existing owner), reliable delivery with a visible failure state, several CRMs or sources, or control over where personal data goes. If you are still deciding between systems, read custom CRM or ready-made, and design stages and statuses first: how to design a sales pipeline. For the wider picture of exchanging data between systems, see CRM and ERP integration.

  • A form or no-code connector is enough: low volume, one owner, no custom rules, a lost lead is not costly.
  • Write a small service: several managers with rules, repeat clients, need to see failures, ad traffic where every lead has a price.
Questions

FAQ

Didn't find an answer — ask on the call or in Telegram.

How do you connect a Telegram bot to a CRM to capture leads?

Make the bot collect a few fields, save the lead in your own database, then let a background worker create the contact and deal through the CRM API. The worker searches for an existing contact, sets the responsible manager and stores the CRM id. If the CRM fails, it retries. Never send to the CRM straight from the dialogue.

How do you integrate a Telegram bot with amoCRM or Bitrix24?

Both have REST APIs. In amoCRM, the complex lead method creates a lead with a contact in one request. In Bitrix24, you create the lead or deal and look for duplicates by phone with crm.duplicate.findbycomm. Check the current documentation for authorization and limits, and keep the integration code in one service, not inside bot handlers.

How do you avoid duplicate leads from a Telegram bot?

Normalize the phone number, search the CRM before creating anything, and attach new requests to the existing contact. On your side, keep one open lead per Telegram user and a unique key per lead, so a retry cannot create a second deal. CRM duplicate control helps, but do not rely on it alone.

What happens to leads if the CRM is unavailable?

They stay in your database with a status such as "new" or "failed", and a worker retries with growing delays. The person has already been told the request is received. When the CRM returns, delivery continues. Alert yourself when leads wait longer than expected, so a long outage is noticed quickly.

Do I need user consent for a Telegram lead bot?

A bot that collects a name and phone number processes personal data, so you typically need a clear notice and, depending on your country, consent. Show the text and a policy link before asking for contacts, store the fact and date with the lead, and agree the exact wording with a lawyer.

When is a form or no-code connector enough instead of a custom bot?

When volume is small, every lead goes to one person and losing the occasional lead is cheap. Once you need assignment rules, repeat-client handling, visible failures or several CRMs, a small custom service is easier to live with than a chain of connectors.

Related service

Telegram bot development for business

A bot is a way into your system in the place where customers and staff already talk. We build bots as full applications — with a database, permissions and integrations — not as a set of buttons.

Learn about the service
Other articles
Contact

Shall we discuss your task?

Thirty minutes on a call — and you understand the architecture, timeline and engagement format. No obligations.

Or message us on Telegram →Follow our Telegram channel →

Enter your Telegram or email so we can reply.

We reply within 15 minutes.