CRM Integration – how to pass the DID (called public number) on inbound calls?

oneam

Customer
Basic Certified
Joined
Oct 7, 2024
Messages
16
Reaction score
4
Hi everyone,

I've set up a CRM Integration (XML template) that sends call data to our own CRM through the template variables.

On inbound calls everything works except one thing: I can receive the extension that handles the call, but I can't manage to pass the DID / public number that was called. I need both in the request to my endpoint:

1. the extension involved in the call (already working);
2. the DID / public number the inbound call came in on (currently missing).

I need the DID because on the CRM side I have to know which public number the call landed on, in order to route/associate it correctly.

A couple of questions:

- Which template variable exposes the DID / called number on inbound calls? I've tried the usual [Number] / caller-callee variables, but they return the caller's number and the extension, not the public DID.
- Is there a way to have the template send the extension and the DID together, in the same request?

Setup:
- 3CX version: V20 Update 9
- Integration: CRM Integration (XML template)
- Direction affected: inbound only

Any pointer to the right variable or a working template example would be hugely appreciated.

Thanks!
 
Last edited:
  • Like
Reactions: Evolute IT
The DID isn't available during the CRM lookup.
 
Other solutions?
 
Actually, you shouldn't be able to send the extension either. Just the caller's (external) number is sent. The CRM lookup is triggered as soon as the call is received, even before the call is routed to the extension...

The only way to achieve this would be using the Call Control API. With this API you can monitor calls in the system in real-time, and invoke your API when you see a call routed to an extension. You can get the DID as well from these notifications.
 
  • Like
Reactions: Evolute IT
Thanks for the replies. Let me clarify exactly what I'm seeing on V20 Update 9, because the CRM template route doesn't fit my case.

I'm already using the Call Control API (GET /callcontrol/{ext}). On an inbound external call I correctly get:
- the caller's number (party_caller_id)
- the operator extension that handles the call (dn)

But I do not get the public DID number the caller dialed. Here is a real participant payload from an inbound call (caller anonymized):

{
"status": "Ringing",
"party_caller_id": "+39XXXXXXXXXX",
"party_dn": "10000",
"party_dn_type": "Wexternalline",
"dn": "202",
"callid": 85
}

party_did is absent/empty in every call state (I logged both Ringing and Connected). party_dn is always 10000 — the trunk LineId — which is the same for all my public numbers, since I have multiple DIDs on a single SIP trunk, all redirected to one operator extension.

So:
- I know which extension is ringing
- I cannot tell which public number the caller dialed, and that's exactly what I need (to attribute the call to the right source).
 
OK, so you're on the right track.

What you need to know is that every call in 3CX has 2 legs, one incoming and one outgoing. The DID is only available on the leg associated with the SIP Trunk, in your case the DN "10000". So you must do the following:
1) Listen for notifications for the ExternalLine DN 1000.
2) Store the data for every call received, so you keep the DID in memory.
3) When you receive a notification from an extension, use the Call ID to match the Call ID from the other leg, and this way get the DID.
4) With all the information you can invoke your API.

You will need to also listen for call end events, so you clean up your data structure in memory when the call ends.
 

Members Online Now

Forum statistics

Threads
111,831
Messages
589,277
Members
164,660
Latest member
RJenkinsROCK