Book Image

Freeswitch 1.6 Cookbook

Book Image

Freeswitch 1.6 Cookbook

Overview of this book

FreeSWITCH 1.6 Cookbook is written for anyone who wants to learn more about using FreeSWITCH in production. The information is presented in such a way that you can get up and running quickly. The cookbook approach eschews much of the foundational concepts, and instead focuses on discrete examples that illustrate specific features. If you need to implement a particular feature as quickly as possible, then this book is for you.
Table of Contents (14 chapters)
FreeSWITCH 1.6 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 on that input. With these basic concepts demonstrated, you will 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 have read the Establishing an outbound event socket connection recipe 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...