DID Session Variable?

Hi All,

I’m trying to figure out how to best make use of DID routing using the inbound routes feature.

Currently my VOIP provider (callcentric) passes information on the DID called in the SIP_HEADER(TO) variable. The information is passes as:

<sip:[email protected]>

I’d like to parse this SIP_HEADER(TO) to get the DID from it and set an appropriate variable so that my incoming route can route it so a particular destination.

I’ve got several DIDs that I would like to route differently.

Currently I can do this in extensions_custom.conf by setting up the following context:

exten => s,1,Set(Var_TO=${SIP_HEADER(TO)})
exten => s,n,GotoIf($["${Var_TO}" = "<sip:[email protected]>"]?from-did-direct,111,1)
exten => s,n,GotoIf($["${Var_TO}" = "<sip:[email protected]>"]?app-daynight,0,1)
exten => s,n,GotoIf($["${Var_TO}" = "<sip:[email protected]>"]?custom-changednum,s,1)
exten => s,n,GotoIf($["${Var_TO}" = "<sip:[email protected]>"]?app-daynight,0,1)
exten => s,n,GotoIf($["${Var_TO}" = "<sip:[email protected]>"]?from-did-direct,120,1)
exten => s,n,Goto(app-daynight,0,1)
exten => h,n,Macro(hangupcall)

However, I’d like to get rid of as much custom context as possible and let FreePBX handle the routing.
Any ideas what variable I can set to the parsed DID number PRIOR to the call hitting the inbound routes?

Thanks for any suggestions.

jimbo

intercept it in your custom context, then once you have the proper DID, send it on to from-pstn: goto(from-pstn,YOURDID,1).

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

What is the best custom context to use in this case? Basically from what context to I intercept from?

Thanks for the reply

just make a context, e.g. [from-my-trunk-that-needs-custom-processing] …

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

yeah, got that.

I’ve got a custom context [from-pstn-custom] but it doesn’t seem to get hit when an incoming call comes in.

Interestingly, if I simulate an incoming call by dialing 7777 it hits the context, however when an incoming SIP call comes it never gets hit.

I just don’t know where to “hook” my custom context into the dialplan so it gets executed.

in your trunk, don’t put from-pstn, put from-whatever-the-name-of-your-context-is and it will go there.

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

ahh. OK got it.

Thanks for the help! much appreciated!

In case anyone else needs this info, I was doing this in order to handle DID routing when using Callcentric.com as a SIP provider. They pass the DID info in the SIP_HEADER(TO) field.

More on this here: http://nerdvittles.com/forum/showthread.php?t=258