Upgrade 3CX to v18 and get it hosted free!

Asterisk cmd SetVar

Author image

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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.