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
:
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>
Save the file, launch
fs_cli
, and issuereloadxml
, or press the F6 key:Our Dialplan is now ready to call the Lua script named
test1.lua
. Create this new script as follows.Using your text editor, create the
test1.lua
script in thefreeswitch/scripts/
directory, and add the following code lines:-- test1.lua -- Answer call, play a prompt, hang up -- Set the path separator pathsep = '/' -- Windows users do this instead: -- pathsep...