Skip to content
Anton GoncharovAI systems developer

Python backend · webhooks → amoCRM and Bitrix24

Lead integration hub

Leads come from a dozen places, and each sends them its own way: Tilda as a form, an online store as a signed order, Yandex Direct and VK as lead forms, the phone system as a call event. Some get lost, some get duplicated, and when the CRM goes down for a minute, leads disappear silently. The hub takes everything into one point, cleans it, scores it and passes it to the CRM through a queue — so that no lead is lost or created twice. Here you get your own sandbox for 24 hours: a real Python service, your own webhook URLs and simulations of two CRMs you can break.

Scenario: Zerno roastery — fictional: wholesale for coffee shops and offices, an online store, ads on Yandex Direct, VK and Avito, calls and email. The managers and customers are fictional too.

Demo screenshot: Lead integration hub

Open the demo

The sandbox is created with one button and lives for 24 hours. The quiz, widget and voice request in the same browser send leads to it automatically, and the lead bot does so after you follow the link from the sandbox.

The app runs in your browser: nothing is sent to a server.

What the demo shows

  • 12 sources: Tilda, WooCommerce, JSON from any website, Yandex Direct, VK Ads, Avito, phone system calls, email, the quiz, the widget, the voice request and the bot in Telegram and Max

  • Each source has its own format and protection: an HMAC signature for WooCommerce and the bot, a token for Direct, a confirmation string for VK, a phone system signature

  • Cleaning: phones in one format, region by number prefix, a corrected name, UTM tags or the source by webhook URL

  • Duplicates: a repeat request within 30 days doesn’t create a new deal but is added as a note to the old one and stays with the same manager

  • Lead scoring and routing by rules: wholesale or retail, which manager, which tag; the rest round-robin

  • Delivery through a PostgreSQL queue: retries after 5 s, 15 s, 45 s, 2 and 5 minutes, a dead-letter queue and manual retry

  • Simulations of amoCRM and Bitrix24 with their methods and responses: rate limits, errors, “every other time”, timeouts and an expired OAuth token

  • A trace of every lead from the raw request to the deal, real-time events and a “Code” tab with the hub’s sources

How to try it

  1. Create a sandbox

    The “Sources” tab has webhook URLs and keys. Press “Send example” for Tilda, Direct or calls — you’ll see the request in the service’s format and the hub’s response.

  2. Send a real lead

    Take the quiz or leave a phone number in the widget — the lead arrives in the sandbox automatically. Or message the lead bot via the link from the sandbox.

  3. Follow the lead’s path

    The “Lead” tab: how the hub cleaned the phone, determined the region, scored the lead, which rule chose the manager and when the deal appeared in the CRM.

  4. Break the CRM

    In the “Delivery” tab, set amoCRM to “Error 500” and Bitrix24 to “Timeout” and send a couple of leads: the hub retries, loses nothing and creates no duplicates.

No paid neural networks

The hub is real: a Python service (FastAPI, SQLAlchemy, PostgreSQL) on this same server accepts webhooks and runs the queue and retries. Instead of amoCRM and Bitrix24 accounts there are simulations with the same methods and responses, including failures. Scoring and routing are rules, without neural networks. The sandbox and its leads are deleted after 24 hours.

The demo runs without OpenAI, YandexGPT or GigaChat API keys. Wherever a production system calls a model, there’s a local stub with the same interface — so the demo is free, always available and never makes things up.

What a production project adds

  • Real amoCRM and Bitrix24: an OAuth app or an incoming webhook, your own fields, pipelines and users
  • Connecting sources in their dashboards: Tilda, WooCommerce, Direct, VK, Avito, the phone system, a mailbox
  • Notifications to managers in Telegram or Max about hot leads and when the CRM isn’t accepting leads
  • A source report: how many leads, duplicates and deals each ad brought
  • Queue monitoring and alerts, database backups, a month of request logs

Stack

  • Python 3.14
  • FastAPI
  • SQLAlchemy 2 (async)
  • PostgreSQL
  • Alembic
  • httpx
  • SSE
  • Docker
  • React 19
  • TypeScript
  • Zustand

Based on

Books and university courses whose ideas are at work in this demo.

  • Book · Andrew S. Tanenbaum, Herbert Bos

    Modern Operating Systems

    Delivery to CRM is asynchronous and parallel: while one CRM isn’t responding, the other leads don’t wait.

  • University course · CMC MSU

    Databases

    A delivery queue in PostgreSQL on SELECT … FOR UPDATE SKIP LOCKED, Alembic migrations, a 30-day duplicate check.

  • University course · CMC MSU

    Operating Systems

    The lead hub runs in Docker on Linux, and delivery to CRM runs as background jobs alongside lead intake.

  • University course · CMC MSU

    Python Development

    The lead hub: FastAPI, async SQLAlchemy 2, Alembic and httpx.

Developer’s comment

Anton Goncharov

AI systems developer · Python

For business

  • No lead gets lost, even when the CRM is down for a minute: the hub retries delivery on its own.
  • A repeat inquiry doesn’t create new deals — it’s appended to the old one and stays with the same manager.
  • Website, ads, calls, email and bots — in one place and one format; you can see which ads bring leads.

For developers

  • FastAPI, async SQLAlchemy 2 and PostgreSQL. The webhook accepts, cleans and saves the lead, and it goes to the CRM through a queue — the source doesn’t wait for the CRM.
  • The queue is built on SELECT … FOR UPDATE SKIP LOCKED, without Redis or a broker: retries from 5 seconds to 5 minutes, then the dead-letter queue.
  • Each source has its own adapter to the common lead format and its own verification: an HMAC signature, a token or a confirmation string.

Tips

  • Tip 01

    Accept a webhook quickly and do the heavy work later: the sender shouldn’t have to wait for your CRM.

  • Tip 02

    Build duplicate protection from day one: everyone gets repeated requests, but only those who didn’t think about it get duplicates.

Want the same for your business?

Tell me about your task — I’ll tell you what from the demo fits, how long it will take and what I’ll need from you.

Other demos in this section

All demos
  • Web app · speech recognition · neural network in the browser

    live

    Voice request

    A customer dictates a request by voice, and the manager gets a ready card: name, company, phone, budget, timeline, task and a score — hot lead or not. Speech is recognized by Whisper right in the browser.

    • React
    • TypeScript
    • In-browser neural network
  • Web app · call in the browser · speech recognition and synthesis

    live

    Voice delivery operator

    A robot takes phone orders instead of the host: it listens, asks again, checks the address against delivery zones, totals the order and reads it back before confirming. The call runs right in the browser — a “Call” button, no phone number.

    • React
    • TypeScript
    • In-browser neural network
  • Web app · speech recognition · sales team quality control

    live

    Call speech analytics

    A sales call becomes a transcript by role, a score against the script and a completed deal card: customer, contacts, interest, the quoted price, the next step and a task for the manager. Speech is recognized by Whisper right in the browser.

    • React
    • TypeScript
    • In-browser neural network
  • Web app · documents · DOCX and PDF

    live

    Proposal and contract generator

    A manager fills in a deal form — buyer, products, discount, VAT — and the commercial proposal, supply contract and invoice are assembled on an A4 page before their eyes. The output is Word, PDF or JSON.

    • React
    • TypeScript
  • Web app · B2B · proposal in PDF

    live

    Price configurator

    A manager builds an order for all the windows in an apartment: type, size, sashes on a diagram, profile, glazing unit and color. Production rules are checked instantly, discounts and installments are calculated automatically, and a numbered proposal goes out as a PDF.

    • React
    • TypeScript
  • Web app · finance · comparison

    live

    Mortgage calculator

    Five bank programs on one screen: which suit the client and why the others don’t. A developer-subsidized rate, differentiated payments, early repayment, debt-to-income ratio and the tax deduction.

    • React
    • TypeScript
  • Web app · estimate · PDF

    live

    Renovation estimate calculator

    Room dimensions turn into floor, wall and ceiling areas, and those into work by stage. Labor and materials separately, the timeline based on crew output, a payment schedule and estimate versions for negotiating with the client.

    • React
    • TypeScript
  • Web app · storefront · checkout · orders

    live

    React SPA catalog

    A whole store in the browser: search with suggestions and keyboard layout correction, facets with live counters, links to any filter, favorites, a cart with a promo code and checkout with a delivery slot. Orders are visible in “My orders” with statuses and can be repeated or cancelled.

    • React
    • TypeScript
  • Machine learning in Python · runs in the browser

    live

    Marketplace review analytics

    Reviews from Wildberries, Ozon and Yandex Market via the seller API: scikit-learn models determine sentiment and what buyers write about, an alert fires in the first week of a complaint spike, new topics are discovered automatically, and replies go back through the marketplace API. The models train right in the browser.

    • Python
    • React
    • TypeScript
  • Website widget · vanilla JS · one line

    live

    AI consultant widget

    A consultant for any website, installed with a single line: it answers from a knowledge base with a link to the source, collects requests and calls an operator. Written in plain JavaScript without frameworks — the whole widget is 21 KB gzipped.

    • Vanilla JS
  • Website widget · vanilla JS · leads

    live

    Quiz lead form

    A quiz instead of a long form: six questions with branching and a price estimate at the end. The manager gets a lead rated “hot / warm / cold” with its ad source, and the “Analytics” tab shows at which step people leave.

    • Vanilla JS