Lua Processing Scripts

You can use Lua functions to perform additional processing for your tasks. For example, if you have a conversation task that sets up the options that a user wants to use to open an account, or make a transaction, you might use a Lua function to call out to an external system to perform the final action.

You can create only one Lua script for your conversation system. You specify the path and file name for this script in the lua_script property in your task configuration JSON file. You can then call out from the configuration for an individual task to a particular function in the script file. For example:

tasks : [ ... ], lua_script : "C:\AnswerServer\Scripts\TaskProcessing.lua", validators : [ ... ] }

You can use a full or relative path. Relative paths can be relative to the Answer Server working directory, or relative to the directory that contains your task configuration JSON file (Answer Server checks for the file relative to the working directory first).


You can specify only one Lua script, even if you split your task configuration across multiple JSON files.

In your individual task configurations, you can specify the following properties to set Lua scripts:

All pre, post, and cancel action Lua functions must accept a taskUtils object.

You can also use Lua functions in your validators, to validate user input:

You can use any of the standard Lua functions and methods in your Lua functions, as well as several custom conversation system Lua methods. The conversation Lua options include simple methods to get and set task and session variables, and a method to forward a question to your other Answer Server systems.

For more information about the Lua functions and methods available, refer to the Answer Server Reference.