Syntax to export a variable in extension dial string

Hello -

I am trying to export a variable to the dial string in an extension.

Here is an example:

In a trunk I can send a variable to the dial string:

Local/[email protected]

I want to do a similar thing in extensions, forwarding the DID info to an adjacent system:

So in a custom extension I added


The __FROM_DID variable is set in ext-did fro $EXTEN

I was also not sure on the syntax of the variable I would think that


would work as this is the standard dial syntax. However with dialparties.agi I am not sure.

Functionality I am trying to achieve is to be able to forward a DID or range of DID’s to an adjacent system trunked via IAX2.

Scenario is main office has PRI and want to route a range of DID’s to a remote office. Creating a custom extension and a route per DID is cumbersome.


I would just do it in extensions_custom.conf.

Something like:

  1. context=from-my-pri for the PRI config
  2. create that context so it looks something like:
include => from-pstn
exten => _212555123X,1,Dial(IAX2/myiaxtrunk/${EXTEN})

where _212555123X is your pattern of DIDs you want to send elsewhere. And you can have multiple entries if you choose.

Thanks Philippe -

That’s where I am at now and it works great. Problem is that makes it a Scott only solution and my techs can’t route DID’s to remote offices. A common request.

If I could get a misc destination or anything that I would use the inbound route module.

I was also thinking about adding another global variable, DID_out or some such thing and in a custom context move set $EXTEN to DID_out and then I can use it in the dial string of a custom extension?? With this solution I make one custom change.

I have one more thought…

What if add something like this to extensions_custom:

exten => s,1,Dial(IAX2/myiaxtrunk/${EXTEN})
exten => s,2,Hangup

Then use the custom destination module to send the inbound route to ‘to-Painesville-remote’


one of the more important reasons I suggest doing what I proposed was that if all you are doing is switching the DID, you probably want to minimize all of the manipulation that otherwise occurs when processing a number.

It sounds like a better overall solution may be a new module for the pure purpose of doing this, or a new module that introduces destinations just for inbound routes though it still then goes through all the inbound route code.

Yes, I need to find it however it has been in the hopper, it did not make it into 2.6.

Seems to me it would be a very simple module. Any chance a bounty could make it into 2.6?

Not sure of the scope of the variable(s) over IAX, but is not

the value(s) you’re looking for that flow in the “channel” for the scope of channel.



you could request on the Forums about a bounty or contact FreePBX support about the cost to make the module or mods, that would be the best route.