• News
  • Idefisk
  • Tools
  • Tutorials
  • Forum
  • Reviews
  • VoIP Providers
  • Archives
  • Gallery
ZOIPER softphone
Back to Tutorials

6.1.2.80. Set (dialplan application)

1. Set - this application allows you to set a value to a variable.

NOTE: This application is valid for Asterisk version 1.0.9 and above.

 


Syntax:

Set(name1=value1|name2=value2|..[|options])

here you can set up to 24 pairs of variable_name – value. You can inherit a variable into channel inherited from the current channel when you define the variable with underscore prefix (_var). When you declare the variable with double underscore prefix (__var) it will be inherited infinitely into all child channels. When you define a variable with underscore prefix to double underscore prefix you call the variable omitting the underscore(s). The only option available is “g” – sets the variable globally instead of only in the channel (valid only for variables not for functions).

 


Purpose and usage

This dial plan application is used for assigning value to a variable. In Asterisk dialplan application we can see that applications like SetCIDName, SetCIDNum, SetLanguage, SetVar are being deprecated in favour of Set ( Set(CALLER(name)=…), Set(CALLER(number)=…), Set(LANGUAGE()=…)).

Have a look at the example below.

 


Prerequisites

First of all you need to install Asterisk PBX. Afterwards you need to configure at least one user in iax.conf, sip.conf or mgcp.conf – the protocol you are going to use depends on you or of the phone you are using. After this you need to write some extensions in extensions.conf.

In this tutorial I will use Idefisk softphone that is an IAX client. You can download it by clicking here. Tutorial showing how it works and configuration support can be found here.

 


Asterisk PBX configurations

NOTE: This is just an example of what you can use this application for. Of course you can use it and for other purposes.

When you have installed and working Asterisk PBX you will need some user to test this application. If you do not have any registered in iax.conf you may add the following one. If you are not going to user Idefisk Softphone and iax.conf you have to register the user in the same way in sip.conf, h323.conf or mgcp.conf – depending on the protocol you are using.

set_user.png

So, we have registered the users anatoliy, user1 and user2.

Type=friend means that this user can make and receive calls. Host=dynamic means that the IP is not static but dynamic through a DHCP server. Allow=all means that the line which this user will use, could support all audio codecs. Context=test - this shows that this user is working with the extensions in this context of the configuration file extensions.conf.

We now have a user that can use the context [test] from extensions.conf. So now we need some dial plan application in [test] in extensions.conf.


set_extensions.png

Here is the application in extensions.conf. Note that the priority “n” is used. This means that the priority will be the next number – so I just give the initial value 1 and then the priority will increment with one each time.

NOTE: When you define a variable _var or __var you just call it ${var}.

If you see unknown so far applications for you have a look at the following tutorials:

Answer

Playback

Dial

NoOp


exten => 123,1,Answer()
The call is answered.

exten => 123,n,Playback(welcome)

Welcome message is played on playback.



exten => 123,n,Set(a=aaa)
Variable “a” is defined and value “aaa” is assigned to it.

exten => 123,n,Set(_b=${EXTEN})
Variable “b” is defined and value “${EXTEN}” is assigned to it. It is defined with underscore prefix, so it will be inherited in the inherited channel. ${EXTEN} is an asterisk-defined variable and is case sensitive and returns the extension you have dialed.

exten => 123,n,Set(__c=${CALLERID})
Variable “c” is defined and value “${CALLERID}” is assigned to it. If is defined with double underscore prefix, so it will be inherited in every inherited channel. ${CALLERID} is an asterisk-defined variable and is case sensitive and returns the caller id.

exten => 123,n,Dial(Local/alpha@test)
This dials locally the extension alpha at the context test. Usage is: Dial(Local/extension@context).
For more information have a look at the dial tutorial.

exten => alpha,1,Answer()
The call is answered.

exten => alpha,n,NoOp(${a})
Variable “a” is dumped in CLI

exten => alpha,n,NoOp(${b})
Variable “b” is dumped in CLI

exten => alpha,n,NoOp(${c})
Variable “c” is dumped in CLI

exten => alpha,n,Dial(Local/bravo@test)
This dials locally the extension bravo at the context test. Usage is: Dial(Local/extension@context). For more information have a look at the dial tutorial.

exten => bravo,1,Answer()
The call is answered.

exten => bravo,n,NoOp(${a})
Variable “a” is dumped in CLI.

exten => bravo,n,NoOp(${b})
Variable “b” is dumped in CLI.

exten => bravo,n,NoOp(${c})
Variable “c” is dumped in CLI.

exten => bravo,n,Hangup()
HangUp() closes the channel line.


 

2.The application in CLI


set_phone.png
set_CLI.png

Here is what you will see in CLI. When the call is answered and welcome message is played variables “a”, “_b” and “__c” are set. Then you are redirected to the next channel – alpha. When the channel is answered the variables are dumped and send to another channel – bravo. The channel there is answered and again the variables are dumped and the channel is closed. The variable a is valid just for the 123 channel and variable __c is valid as for the channel 123 so for all inherited channels (alpha and bravo).

 


3. Additional information

For more information about extensions.conf you can check here.
For more information about iax.conf you can check here.

This application is tested with our IAX softphone Idefisk. You can download it from here. For more information about this softphone please read our tutorial.

If you would like to test this application with the SIP channel you can read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX

 


4. Similar dialplan applications

SetVar()
SetCallerID()
SetCIDNum()
SetCIDName()
SetLanguage()

 

 
Add Comment
Name:
Email:
Comment:
In order to prevent automatic posting on our website, we kindly request you to type in the number you see in the picture below.
Image Verification:
 

Latest Headlines:

  • T.38 faxing with Zoiper 2.15 is now easier than ever
    section: voip software
  • Asterisk 1.4.21 Released
    section: Asterisk
  • Asterisk 1.4.20 Released
    section: Asterisk
  • Asterisk 1.4.20-rc2 Released
    section: Asterisk
  • Asterisk 1.4.20-rc1 Now Available
    section: Asterisk
  • News Archives (older news)

Latest Tutorials:

  • Sending Fax from Zoiper to Zoiper using T.38
    added 08/Dec/2008 18:16
  • VMAuthenticate (dialplan application)
    added 01/Mar/2008 15:57
  • Siptronic ST-530
    added 06/Nov/2007 17:57
  • Siemens C455 IP hardphone
    added 05/Nov/2007 10:24
  • Zoiper
    added 22/Oct/2007 17:53

Latest Comments:

  • nice...
    tutorial: X-Lite - SIP softphone
  • Badly need your help. Things are only im...
    tutorial: Grandstream HandyTone-486 - SIP Analog Telephone Adapter (ATA)
  • how do i rectify this problem? all incom...
    tutorial: Troubleshooting
  • How are you. Summer afternoon - Summer a...
    tutorial: Cisco 7960 IP Phone - SIP firmware version
  • where is the tar file you mention above ...
    tutorial: Cisco 7960 IP Phone - SIP firmware version
 
contact us at: support@asteriskguru.com - asterisKGuru.com © all rights reserved   |   *asterisk is registered trademark of © Digium™