---
id: 18499
lang: en
title: "A plain JOIN turns one deal into 12 funnel events: how to connect CRM and call analytics"
published_at: "2026-11-28 00:32:43"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1112968/?utm_campaign=1112968&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/18499"
categories: ["llm", "business"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# A plain JOIN turns one deal into 12 funnel events: how to connect CRM and call analytics

> **Краткая суть (BLUF):** A CRM stores deals, speech analytics captures what was actually said in conversations, and when the two are joined carelessly, the report starts to lie. One deal with three calls, each producing four events, yields 12 rows from a plain JOIN, and COUNT(*) reports 12 "funnel events" instead of one deal. The fix is a table that links calls to deals, plus a unique call ID. So check duplicates and attribution first, and only then build the dashboard.  • A repeated telephony notification will double objections unless the call ID has a UNIQUE constraint. • Count deals with COUNT(DISTINCT deal_id) and events by event_id. • Store call time, event time, load time and stage-change time separately, in UTC.

Picture a dashboard showing 12 "funnel events" where in reality there is one deal. This happens when CRM data (which holds deals and stages) is joined with speech analytics (which finds the customer's needs, price objections and agreements to meet in call recordings). One deal has three calls, with four events in each. A plain JOIN, meaning a table merge on a shared key, produces 3 × 4 = 12 rows, and COUNT(*) counts all of them as separate funnel events. The report looks convincing, but its numbers are wrong, and wrong conclusions on a polished dashboard are more dangerous than having no dashboard at all. Let's look at where the link breaks and how to build a minimally reliable model.

## Why one phone number is not enough

Take a typical case. At 10:00 a customer calls a manager to clarify product specifications. At 14:00 they call back about delivery. The next day, another employee discusses an additional service with them. In the CRM there is one customer card, two deals and three calls.

If conversations are linked to deals only by phone number, the first deal will receive events from the conversation about the second one. The system will hear a "price objection" during the discussion of an add-on service and attribute it to the sale of the main product. The result is a false link between the quality of a consultation and a deal's movement through the funnel.

The way out is a minimal model of four entities: deal, call, call_deal_link and speech_event. The link table is the key piece. It stores not only the fact of matching but also the method: a CRM identifier, a telephony event, or a less reliable heuristic such as "by contact and time", plus a confidence level. If there are several candidate deals, it is more honest to mark the link as ambiguous than to silently pick the first suitable one.

## Duplicates, idempotency and time

Telephony can send a call-completed notification twice: once immediately and once more from a message queue. If the handler creates a new record each time, one call becomes two, and speech analytics counts the same need or objection twice.

The protection is a stable external call identifier and idempotent insertion, meaning an insert that can be repeated without side effects. In PostgreSQL this looks like INSERT ... ON CONFLICT (external_call_id) DO NOTHING, with a unique constraint on that field. If there are several telephony sources, the key is made composite: the system identifier plus the call identifier.

The second common mistake is confusing call time with the time analysis results arrive. A call ends at 18:00, processing finishes at 18:12, and at 18:05 the manager has already moved the deal to the next stage. If processing time is used, it looks as though the objection was raised after the status change, when in fact it came before. So the following are stored separately:

- the time the call started;
- the time of a specific event within the conversation;
- the time the processing results were loaded;
- the time the deal's stage changed.

All of this is recorded in a single time zone, such as UTC, and converted to local time only for display.

## How not to multiply rows

Back to the original 12 rows. Deals are counted with COUNT(DISTINCT deal_id), and events with a separate aggregation by event_id. These are different metrics, and mixing them in one row set after a JOIN is dangerous.

## Model errors and causality

Even a perfect integration does not guarantee correct semantic conclusions. The model may take an ordinary question about price for an objection, or miss an agreement to meet. So each event should store the model version, the classification criterion, a reference to the source conversation and, where such data exists, a confidence score and manual-review status. Reprocessing calls with a new model version must not quietly rewrite history: versions are stored separately, and the one that feeds reporting is selected explicitly.

There is also a methodological trap. If deals with an agreed next step more often reach a demo, that does not yet prove the agreement itself is the cause. Experienced managers may both secure next steps more often and qualify leads better. For a fair comparison, account for lead source, customer type, manager, deal size and funnel stage.

## Where to start

The author advises a minimal pilot: one deal type, one telephony source and three verifiable events — needs identification, cost discussion, and agreement on the next action. First verify data connectivity, completeness of call transfer, absence of duplicates and classification accuracy. Only then build analytics that connects stage transitions with conversation content.

An important caveat: the scheme described is conceptual, not an integration standard, and the specific fields will need to be adapted to your CRM and telephony. But the conclusion is universal: the difficulty is not passing JSON between systems, but correctly linking calls, deals, events and time. Without that, even a strong speech recognition model will feed data into a warped funnel.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1112968/?utm_campaign=1112968&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/18499
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
