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:
You can also specify a range of users:
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.
conf/dialplan/default.xmlfile in a text editor. Locate the
<extension name="Local_Extension"> <condition field="destination_number" expression="^(10[0-9])$">
Edit the expression in the
<condition>tag to account for our new users. The
^(10[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[0-9])$">
Save the file and then execute
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.
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:
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:
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).
The Creating users section in Chapter 5, PBX Functionality