DID setting for inbound dialplan

Say for example I have the sip trunk with the context [inbcall]

And have DID 12345 and 67890

so what should be the first line with exten=> so that i can define that the calls coming from 12345 should go to SIP/1002 and call coming from 67890 to go to SIP/1003?

Thank you!

How is the DID encoded in the INVITE request?

Are you aware that chan_sip is not supported by Sangoma, and will eventually be removed entirely?

What the SIP community mis-names DIDs are places where calls are going, not coming from.

I believe that the most common way of providing the dialled number indication, from SIP providers, is the To header, so you will need to us the appropriate functions to extract that header and parse out the relevant part of the SIP URI, then probably use GoToIf or ExecIf, to either conditionally set the data part of the dial string, or to select an appropriate Dial() instance. I guess you might get away with one line, but the code will be easier to read if you do it a step at a time.

I believe that FreePBX has standard code for extracting this information, although it probably assumes the To URI. I don’t if it does it in pure dialplan, or uses AGI.

This article may help if the DID is encoded in the To header:

Simplest possible answer:

[inbcall]

exten => 12345,1,Dial(SIP/1003)
exten => 67890,1,Dial(SIP/1004)

This provides exactly what the OP asked for.

  • Darrin

Technically true, but it makes assumptions that the OP left open, but which are not normally true. The much more common case is that the system registers with the provider, and the request URI is always the account name or s. Having an account per number is not how direct in dialling is supposed to work. This is why my first question was how is the DID identity encoded in the request.

Maybe…

To me, ‘from’ means CID (Caller ID), ‘to’ means DID (Direct In[ward] Dial).

I almost commented on that in my initial reply, but decided that the OP couldn’t reasonably have meant from. I think this largely comes down to the SIP community use of DID, where the real DID is to the ITSP. With real DID I would expect a single, contiguous block of numbers, rather than a random selection. However, the way I find the SIP community tends to use it is to refer to a single PSTN number rented from a SIP provider.