Book Image

FreeSWITCH Cookbook

Book Image

FreeSWITCH Cookbook

Overview of this book

FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice, chat, and video applications. It can scale from a soft-phone to a PBX and even up to an enterprise-class softswitch.In the FreeSWITCH Cookbook, members of the FreeSWITCH development team share some of their hard-earned knowledge with you in the book's recipes. Use this knowledge to improve and expand your FreeSWITCH installations.The FreeSWITCH Cookbook is an essential addition to any VoIP administrator's library.The book starts with recipes on how to handle call routing and then discusses connecting your FreeSWITCH server to the outside world.It then teaches you more advanced topics like CDR handling, practical examples of controlling FreeSWITCH with the event socket, and configuring many features commonly associated with a PBX installation.
Table of Contents (12 chapters)
FreeSWITCH Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Internal calls


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.

Getting ready

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:

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

How to do it...

Follow these steps:

  1. Open the file conf/dialplan/default.xml in a text editor. Locate the Local_Extension entry:

    <extension name="Local_Extension">
      <condition field="destination_number"expression="^(10[01][09])$">
      ...
  2. Edit the expression in the <condition> tag to account for our new users. The expression pattern ^(10[012][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[012][09])$">
  3. Save the file and then execute reloadxml from the fs_cli.

Tip

Downloading the example code

You can download the example code files for all Packt 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...

The 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:

^(10[012][0-9])$

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:

^(10[0123][0-9])$

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

See also

  • The Creating Users section in Chapter 5, PBX Functionality