Internal calls
Calling local extensions is very simple once you know what needs to happen. In this case, we will see how to add a new user and make their phone available for calling.
Getting ready
If you are using the default configuration, then users 1000 through 1019 are preconfigured, both in the directory and the dialplan. To add a user beyond this range to the directory, it is generally easier to run the add_user
script, found in the FreeSWITCH source directory under scripts/perl
. For example, to add user 1020 to the directory, launch this script from the FreeSWITCH source directory, specifying the user ID on the command line:
scripts/perl/add_user 1020
You can also specify a range of users:
scripts/perl/add_user –-users=1020-1029
You will see a note about the number of users added to the directory. If you have the Regexp::Assembly
CPAN module installed, then the script will also generate a couple of sample regular expression patterns, which you can then use in the dialplan. For our example, we added a range of users from 1020 to 1029 to the directory, and then we'll add them to the dialplan.
How to do it...
- Open the
conf/dialplan/default.xml
file in a text editor. Locate theLocal_Extension
entry:<extension name="Local_Extension"> <condition field="destination_number" expression="^(10[01][0-9])$">
- Edit the expression in the
<condition>
tag to account for our new users. The^(10[012][0-9])$
expression pattern will do what we need (look closely to see the difference). The new line will be as follows:<condition field="destination_number" expression="^(10[012][0-9])$">
- Save the file and then execute
reloadxml
fromfs_cli
.
Tip
Downloading the example code
You can download the example code files for all Packt Publishing books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
How it works...
Local_Extension
is the default dialplan entry that allows directory users to be called. Remember that simply adding a user to the directory does not mean that the user can be dialed. (However, it does usually mean that the user can make outbound calls.) So, in order for your new user to be reachable, you need to add their user ID to the dialplan. By default, Local_Extension
has a regular expression that will match 1000, 1001, and so on up to 1019. After adding that number range, it is necessary to modify the regular expression to account for those new numbers. In our example, we added user IDs 1020 through 1029, so we need to match these. We use this regular expression:
^(10[012][0-9])$
This matches 1000 through 1029. Let's say we have added another block of user IDs with the range from 1030 to 1039. We can modify our regular expression to catch them as well:
^(10[0123][0-9])$
It is considered best practice not to add a large range of dialable numbers to Local_Extension
without having the corresponding users in the directory. Doing so can make troubleshooting dialplan issues more difficult.
As a reminder, be sure to execute the reloadxml
command each time you modify the regular expression (the changes you make to your XML configuration files will not take effect until they are loaded into the memory, which is what the reloadxml
command does).
See also
- The Creating users section in Chapter 5, PBX Functionality