Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Freeswitch 1.6 Cookbook

You're reading from   Freeswitch 1.6 Cookbook Over 45 practical recipes to empower you with the latest FreeSWITCH 1.6 features

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781785280917
Length 190 pages
Edition 1st Edition
Concepts
Arrow right icon
Toc

Table of Contents (9) Chapters Close

Preface 1. Routing Calls FREE CHAPTER 2. Connecting Telephones and Service Providers 3. Processing Call Detail Records 4. External Control 5. PBX Functionality 6. WebRTC and Mod_Verto 7. Dialplan Scripting with Lua Index

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...

  1. Open the conf/dialplan/default.xml file in a text editor. Locate the Local_Extension entry:
    <extension name="Local_Extension">
    <condition field="destination_number"
    expression="^(10[01][0-9])$">
  2. 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])$">
  3. Save the file and then execute reloadxml from fs_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
You have been reading a chapter from
Freeswitch 1.6 Cookbook
Published in: Jul 2015
Publisher:
ISBN-13: 9781785280917
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime