Answer Server 25.3
Answer Server Help

# 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).

NOTE: 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:

- The `pre` object `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.

- The `post` object `lua` property 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.
- The `action` object `lua` property (in the `user_cancel` or `system_cancel` objects) specifies the name of a function to run when the user or system cancels the task. See Task Cancellation.

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:

- Lua validator configuration objects allow you to specify the name of a Lua function to use to validate user input. Lua validator functions must accept a string (the text to validate) as the first parameter. You can optionally also use a `taskUtils` object as the second parameter, if you want to use `taskUtils` methods in your validator. See Response Validation.
- The `invalid_input_lua` property allows you to set the name of a function to run when the user input text does not validate. This function must accept a `taskUtils` object. See Process Non-Valid Input.

You can use an additional Lua function to determine the message to return to a user and valid responses from the user when their input triggers multiple tasks. The Lua function must accept a `routingTable` object as the first parameter, which is can use to override the response and options. You can optionally also use a `taskUtils` object as the second parameter, if you want to use `taskUtils` methods in your function. See Default Messages.

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.

Copyright 2016-2025 Open Text
Version 25.3 | Last updated July 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery Answer Server 25.3

Topic Title: Lua Processing Scripts