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

Using the ESL connection object for call control


Sometimes it is convenient (or even necessary) to control a call from a script. In such cases you can use the ESL connection object to control a call from an ESL script. This recipe will demonstrate a simple script that will answer a call, play a prompt, accept some caller input, and then route the call based upon that input. With these basic concepts demonstrated you will then be able to write custom scripts that meet your specific needs.

Getting ready

This recipe is an example of an "outbound" connection from the FreeSWITCH dialplan to an ESL script. As such, you should read Establishing an outbound socket connection earlier in this chapter. This recipe will require at least two terminal windows: one for fs_cli and one for the script. Although the script presented here is written in Perl, the connection object applies to all ESL-enabled languages.

How to do it...

First, add a new extension to your dialplan by following these steps:

  1. Edit or create...