Answer Server 25.4
Answer Server Help

# setTaskVar

The `setTaskVar` method sets the value of a conversation task variable.

You define task variables in your task configuration JSON file, by creating a task requirement with the `scope` property set to local (the default).

## Syntax

    setTaskVar( key, value)

## Arguments

Argument | Description
--- | ---
`key` | (string) The ID of the task variable that you want to set.
`value` | (string) The value to set for the task variable.

## Example

    function favoriteColor(taskUtils)
       local inputcolor = taskUtils:getUserText()
       taskUtils:setTaskVar("COLOR", inputcolor)
       local prompt = LuaUserPrompt:new(string.format("What a coincidence! %s is my favorite color too!", inputcolor))
       taskUtils:setPrompts(
          {prompt}
       )
    end

Copyright 2016-2025 Open Text
Version 25.4 | Last updated October 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.4

Topic Title: setTaskVar