[asterisk-users] Add a variable to the destination channel without adding it to the source channel?

Joshua Colp jcolp at digium.com
Mon Oct 29 10:21:03 CDT 2012


Alexandre Rodrigues wrote:
> Hello all,

Hola,

> I have the following challenge: I have to add a variable to the
> destination channel with the following conditions:
>
>      1) It has to be set in the dialplan, in runtime.
>      2) The source channel can't have the same variable has the destination.
>
>
> I had two ideas so far, but they seem complicated:
>
>      1) Add a local channel in the middle of the source and destination
> channel. With that I can use the
>          dialplan application SET(__VAR='XXX') in the local and it will
> be inherited by the destination channel.
>      2) Call a macro or a gosub in the DIAL. With that macro or gosub I
> can add a variable in the destination channel.

This is a perfect application for pre-dial handlers available in 
Asterisk 11. You can specify a GoSub routine to execute before dialing 
and in that routine you can set the variable you need.

More information is available at 
https://wiki.asterisk.org/wiki/display/AST/Pre-Dial+Handlers

If you are going to use an earlier version you can use the 'U' option to 
execute a GoSub routine before the calling channel and answered channel 
are connected. The caveat with this is that your routine won't be 
executed before dialing actually occurs.

Both of these may seem "complicated" to you because they don't expose a 
single option that just does exactly what you want. This is on purpose, 
we provide many tools to accomplish many different things as what people 
want to do varies greatly.

I hope this helps!

Cheers,

-- 
Joshua Colp
Digium, Inc. | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at:  www.digium.com  & www.asterisk.org



More information about the asterisk-users mailing list