Building voice applications

Now that we have covered the basic Lua syntax, let's create a simple Lua script and the corresponding entry in the Dialplan. First, create a new Dialplan extension that will execute the Lua script when a user dials 9910:

  1. Open the 01_Custom.xml file that we created in Chapter 5, Understanding the XML Dialplan, and add the following new extension:
    <extension name="Simple Lua Test">
      <condition field="destination_number" expression="^(9910)$">
        <action application="lua" data="test1.lua"/>
      </condition>
    </extension>
  2. Save the file. Launch fs_cli and issue reload_xml,or press F6.

Our Dialplan is now ready to call the Lua script named test1.lua. Create this new script as follows:

  1. Using your text editor, create test1.lua in the freeswitch/scripts/ ...

Get FreeSWITCH 1.0.6 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.