Open topic with navigation
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:
lua property specifies the name of a function to run before the task starts. For example, you can use this function to generate an appropriate preamble to send to the user. See Pre-Task Actions.
luaproperty specifies the name of a function to run when all the task requirements have been satisfied. You can use this function to run an external process to complete the task. See Post-Task Actions.
luaproperty (in the
system_cancelobjects) specifies the name of a function to run when the user or system cancels the task. See Task Cancellation.
post, and cancel action Lua functions must accept a
You can also use Lua functions in your validators, to validate user input:
taskUtilsobject as the second parameter, if you want to use
taskUtilsmethods in your validator. See Response Validation.
invalid_input_luaproperty allows you to set the name of a function to run when the user input text does not validate. This function must accept a
taskUtilsobject. See Process Non-Valid 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.