Script input and output variables

String, numeric, and boolean variables have Input and Output properties. When a variable’s Input property is Yes, its value can be set by an external data source. When a variable’s Output property is Yes, its value is saved on the conversation object and may be retrieved programmatically after the call ends. These properties are not mutually exclusive. Either or both can be enabled for a variable.

Variables with these properties enabled are called input variables, output variables or both. Here’s how to understand those terms:

  • A variable is an input variable if its Input property is Yes. Its value can be input from an external source, such as an Architect call flow.

  • A variable whose Output property is Yes is an output variable. When the script runs, any value assigned to the variable is saved for use outside of the script. Its value is output to external storage when the script executes.

  • Since both properties can be set to yes, a variable can be both an input variable and an output variable.

You cannot use dynamic variables as input or output variables.

For new variables, both input and output default to no. If you have existing scripts that use variables, then PureCloud sets input and output to yes for those variables so that scripts are backward-compatible.

Output property

The Output property makes it possible to store the value of a script variable for use after a call ends, without having to set up a data action, or add supplemental columns to a contact list. When Output is set to Yes, the value of this script variable is written to the conversation object. Its saved value may be programmatically retrieved by a customer’s external process for up to 3 months. To use a variable as an output variable, click the output button so that it reads YesScripting output variable

  • When the value of this variable changes during execution of a script, the conversation object is updated in 3 seconds.

  • The conversation object retains stored values for 3 months, before automatically purging them. Currently, data cannot be written to the analytics endpoint, only to the agent attributes of a conversation endpoint. A future enhancement may permit data to be retained indefinitely by using the analytics endpoint instead of the conversations endpoint.

Key/value pairs in the conversation object

Variables are written to the conversation object as key/value pairs. You can retrieve them using the Platform API’s Conversations endpoints. Query the conversation’s participant attributes object using the variable name as the key:

"participants": [
    "attributes": {
      "scripterOutputVariable1": "value",
      "scripterOutputVariable2": "value"
  • If only output is true, then the script attaches the data to the agent participant.
  • If both input and output are true, then the script attaches the data to the participant it found the data on, which in most cases is the customer participant. Otherwise, the default location is the agent participant.

    For example, if the data comes from Architect through an input variable, then Architect places the variable data on the customer participant, and future updates to that variable override the value on the customer participant.

Note: PureCloud adds output variables to v2/conversations, not v2/analytics/conversations. 

Data actions vs. Output variables

The external data action method of saving data from scripts is appropriate for customers who need to output complex information and then route it through stored procedures into a database. The Output property provides a simpler way to save data collected in a script.

  • When Output is set to Yes, string, numeric, or Boolean variables are written to the conversations endpoint of the public API as key/value pairs that can be searched, pulled, and correlated easily.

  • Dynamic and object variables cannot be stored using this process. To save complex object data or dynamic variables, use a data action instead.

Input property

The Input property indicates whether this variable’s value can be set by an outside source, such as an Architect call flow. Set Input to Yes for any variables that you want to receive incoming data for. When Input is set to No, the variable will not accept external values, even if the external source sends a value. To use a variable as an input variable, click the input button so that it reads Yes.

Scripting input variable