Asterisk cmd SetVar

Synopsis

Set variable to value

Partially (?) deprecated: This command will be considered obsolete starting in asterisk 1.2. Use Set instead (except for usage in technology config files like sip.conf?)

Description

Setvar(variablename=value)

Sets a variable variablename to value.
  • Note: Variable names are not case sensitive.

Example 1: Dialplan

Setvar(numTries=4)

Using a variable is nice, because all channels get their own variable space, so there's no chance of collisions between different calls, and the variable is automatically trashed when the channel is hungup.

Try using the variable in your dialplan:

Playback(${variablename})
SayDigits(${variablename})

Example 2: sip.conf

Posted by Joshua Colp dated 12/19/2010, with the subject of "Specifying DID for outbound calls":

I'm surprised nobody has suggested using the setvar functionality. It's
extremely useful for stuff like this and would allow you to keep all
CallerID information with the actual configuration of the device.

Using a configuration entry for sip.conf in another response as an example:

[101]
type=friend
username=101
secret=0000
mailbox=101
callerid="User One" <101>
host=dynamic
nat=yes
dtmfmode=rfc2833
canreinvite=no
reinvite=no
qualify=yes
setvar=EXTERNAL_CALLERID="User One" <3012323434>

And then in extensions.conf:

exten => _1NXXNXXXXXX,1,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN}@vitel-outbound)

Of course you could add some sanity checking there to make sure that
${EXTERNAL_CALLERID} contains a value and if not default to your main DID.

Also you can have multiple setvar(s), i.e.

Setvar=VAR_1=Taco
Setvar=VAR_2=Apples
Setvar=VAR_3=Bannanna

See also


Synopsis

Set variable to value

Partially (?) deprecated: This command will be considered obsolete starting in asterisk 1.2. Use Set instead (except for usage in technology config files like sip.conf?)

Description

Setvar(variablename=value)

Sets a variable variablename to value.
  • Note: Variable names are not case sensitive.

Example 1: Dialplan

Setvar(numTries=4)

Using a variable is nice, because all channels get their own variable space, so there's no chance of collisions between different calls, and the variable is automatically trashed when the channel is hungup.

Try using the variable in your dialplan:

Playback(${variablename})
SayDigits(${variablename})

Example 2: sip.conf

Posted by Joshua Colp dated 12/19/2010, with the subject of "Specifying DID for outbound calls":

I'm surprised nobody has suggested using the setvar functionality. It's
extremely useful for stuff like this and would allow you to keep all
CallerID information with the actual configuration of the device.

Using a configuration entry for sip.conf in another response as an example:

[101]
type=friend
username=101
secret=0000
mailbox=101
callerid="User One" <101>
host=dynamic
nat=yes
dtmfmode=rfc2833
canreinvite=no
reinvite=no
qualify=yes
setvar=EXTERNAL_CALLERID="User One" <3012323434>

And then in extensions.conf:

exten => _1NXXNXXXXXX,1,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN}@vitel-outbound)

Of course you could add some sanity checking there to make sure that
${EXTERNAL_CALLERID} contains a value and if not default to your main DID.

Also you can have multiple setvar(s), i.e.

Setvar=VAR_1=Taco
Setvar=VAR_2=Apples
Setvar=VAR_3=Bannanna

See also


Created by: oej, Last modification: Thu 20 of Jan, 2011 (17:24 UTC) by JustRumours
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+