Calling local extensions is very simple once you know what needs to happen. In this case, we will review how to add a new user and make his or her phone available to be called.
If you are using the default configuration, then users 1000 through 1019 are pre-configured, both in the directory and the dialplan. To create a user outside this range, it is generally easiest to just run the
add_user script, found in the FreeSWITCH source directory under
scripts/perl. For example, to add the user 1020, 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 how many users were added. If you have the CPAN module
Regexp::Assembly installed, then the script will also generate a 'sample regular expression pattern'. For our example, we will add a range of users 1020-1029.
Follow these steps:
<extension name="Local_Extension"> <condition field="destination_number"expression="^(10)$"> ...
Edit the expression in the
<condition>tag to account for our new users. The expression pattern
^(10[0-9])$will do what we need (look closely to see the difference). The new line will be as follows:
<condition field="destination_number" expression="^(10)$">
Save the file and then execute
Local_Extension is the default dialplan entry that allows directory users to be called. Remember, simply adding a user to the directory does not mean that the user can be dialed. (It does, though, usually mean that the user can make outbound calls.) So in order for your new user to be reachable, you need to add his or her user ID to the dialplan. By default,
Local_Extension has a regular expression that will match 1000, 1001, … 1019. When adding users outside 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 those. We use this regular expression:
This matches 1000 through 1029. Let's say we added another block of user IDs with the range of 1030 through 1039. We could modify our regular expression to catch those as well:
It is considered a best practice not to add a large range of dialable numbers in the
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 memory, which is what
reloadxml command does).
The Creating Users section in Chapter 5, PBX Functionality