Book Image

Freeswitch 1.6 Cookbook

Book Image

Freeswitch 1.6 Cookbook

Overview of this book

Table of Contents (14 chapters)
FreeSWITCH 1.6 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using conditionals, loops, web calls, and regular expressions


This recipe helps us demonstrate the loops and other conditionals prevailing in Lua scripts. You will get also familiar with regular expressions and web calls.

Getting ready

Create a dialplan extension 12347 that will call our third Lua script. Edit the /usr/local/freeswitch/conf/dialplan/default/03_advanced.xml file:

<include>
  <extension name="Advanced Lua Script">
    <condition field="destination_number" expression="^(12347)$">
        <action application="answer"/>
        <action application="sleep" data="1000"/>
        <action application="playback" data="ivr/ivr-welcome_to_freeswitch.wav"/>
        <action application="sleep" data="500"/>
        <action application="lua" data="advanced.lua"/>
        <action application="playback" data="ivr/ivr-thank_you.wav"/>
        <action application="hangup"/>
    </condition>
  </extension>
</include>

Save...