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.
- A List variable when used as an input will have the value on the conversation split by comma.
- A List variable when used as an output will have its list joined together by comma on the conversation.
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 Genesys Cloud 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. To use a variable as an output variable, enable Output. When the value of this variable changes during execution of a script, the conversation object is updated in 3 seconds.
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 the variable is output only, then Genesys Cloud applies that variable’s value to the agent participant unless it sees that variable data on another participant; in that case, to keep the data in sync, Genesys Cloud updates the other participant.
- If the variable is both input and output, 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.
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, enable Input.
Customer Secured Data
Output conversation settings for Get Secure Data and Set Secure Data
When the Output option for the variable is enabled, the value of this script variable is written to the conversation object. The customer can programmatically retrieve the value of the variable to allow sensitive data to be outputted during the customer interactions. Ensure to disable the Output option for the variable so that the data entered into this variable is not used in an insecure way during the customer interactions. For more information, see Available script actions. The Get Secure Data and Set Secure Data of the Customer Secured Data feature is the correct way to query and update the sensitive customer data. For more information, see Get Secured Data action and Set Secured Data action.