1. SetCallerID is a dialplan application that sets the ID of the user that calls (ID is composed of name and number).

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

If you are using version 1.2 or newer, then you have to know that this application is deprecated. However, if you want to use its functionality, there is a new syntax, which require the usage of the Set application. For more information click on the link - The new syntax - the CALLERID(all) function.

Syntax:

SetCallerID(clid[|a]) : clid is the parameter that will be the new caller ID. The second parameter will set ANI flag if any are used. It is optional.

The application always returns 0.

Purpose and usage

This dial plan application is used for changing the caller ID.

Have a look at the example below. There are some small tricky issues to be noted:

The caller ID that is set in Asterisk PBX (iax.conf, sip.conf or mgcp.conf) overwrites the caller ID set on the softphone client.

When you use caller ID as variable ${CALLERID} note that as this variable is Asterisk-defined it is case sensitive (must be in capital letters).

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.

Above I registered a user [ivan] with the properties:

type=friend (type might be user – just can call, peer – just can be called and friend – can call and can be called)

username=ivan – this is the user which must authenticate when connecting to the Asterisk PBX server

context=test is the context from extensions.conf which the user can access (including any other context which is/are included in this one)

secret=ivan is the password with which the user must authenticate when connecting to the Asterisk server

host=dynamic means that the host for this user is dynamic and he/she can connect to Asterisk PBX from different computers (host may be defined with static ip address)

Allow=all means that all audio codecs are allowed (You can allow certain codecs as well as disallow others)

Note the settings in the softphone client – here they are important. I am using Idefisk in this tutorial. For better overview of Idefisk you can read the Idefisk configuration tutorial. Here is how the account I am using is set.

As you see in host I set the IP address of my Asterisk PBX. Username and password are the same as the ones defined in the iax.conf file on the asterisk. I set CallerID to ivan and number to 333.

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.

Here is the application in extensions.conf:

exten => 1111,1,Answer()

the call is answered

exten => 1111,2,Playback(welcome)

welcome message is played on playback

exten => 1111,3,NoOp(${CALLERID})

this shows the current value of the caller ID

exten => 1111,4,SetCallerID(test)

Caller ID is set to test here

exten => 1111,5,NoOp(${CALLERID})

shows in CLI the current Caller ID that must was changed.NOTE: the ${CALLERID} above is Asterisk-set variable and is case sensitive.

exten => 1111,6,Playback(vm-goodbye)

goodbye message is played

exten => 1111,7,Hangup()

hangup() closes the line

2. The application in CLI

Look above asterisk gets the caller id from the softphone client – user + number (ivan <333>). Then it is set to test and when dumped with NoOp it shows that the caller ID is changed to test.

Now let us just add to iax.conf on Asterisk this line to the user properties: callerid=user <222>

Then redo the example and here is what happens in CLI.

As you see now Asterisk takes the Caller ID value from the user properties in iax.conf not from the settings of the Idefisk (or any whoever softphone client) – user <222>. SetCallerID sets the caller ID to test. Then we check the caller id with NoOp to be sure that it is changed.

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