Runsub

The Runsub action icon, a curled piece of paper with two arrows pointing to the right next to it at the top and bottom.

Calls a subscript, which runs and then uses the Return action to return to and continue running the main script. When the subscript runs, it stores a value in the ReturnValue property of the Return action and then passes that value back to the ReturnVariable property in the Runsub action on the main script.

This action can be especially useful if you have one or more larger scripts that you'd rather break into smaller scripts.

Dependencies

  • The main script and the subscript must be in the same folder.

  • The main script type and the subscript type must be the same. For example, if the main script is a phone script, the subscript must also be a phone script.
  • If you put a Runsub action in the main script, your subscript MUST have a Return action.
  • Runsub can pass multiple variables from the main script to the subscript, but the subscript can return only one value (in the ReturnVariable property) to the main script.
  • Any variables defined in the subscript will no longer be available when the subscript terminates.
  • All scripts called by RunScript , Spawn, Runsub, or similar scripts must be valid and active. During the save process, Studio validates all scripts called by actions. If any of them are invalid or inactive, Studio displays an error and you won't be able to save.

Supported Script Types

The icon for a Generic script type - a rectangle with < and > symbols inside it.

The icon for the Email script type - a large @ symbol in a diamond.

The icon for the Chat script type - a chat bubble with an ellipsis inside (...), in a diamond shape.

The icon for the Phone script type - an old-style phone handset with curved lines indicating sound coming out of it.

The icon for the Voicemail script type - a symbol that looks like a cassette tape - two circles sitting on a horizontal line.

The icon for the Work Item script type-a piece of paper with one corner folded down and a bullet list on it.

The icon for the SMS script type - a smart phone with a chat bubble coming out of it.

The icon for the Digital script type - a computer monitor with a smartphone next to it.

Generic

Email Chat Phone Voicemail Work Item SMS Digital

Comparison of Similar Actions

The following actions have similar functions, but with some key differences: 

  • Runscript: When Runscript triggers a subscript, there's no way to return to the first script from the subscript.
  • Runsub: When Runsub triggers a subscript, the script can return to the first script, as long as the subscript has a Return action. The Return action provides a value back to the Runsub action when the subscript is finished.

Input Properties

These properties define data that the action uses when executing.

Property

Description

Caption

Enter a short phrase that uniquely identifies this action in the script. The caption appears on the script canvas under the action icon. The default is the action name.

ScriptName

The script you want to spawn. You can click the Choose Script link at the top of the action's properties box to select a script stored for your business unit.

ReturnVariable

The value that is returned to the main script is stored in this property. To pass multiple values, use an array as the variable.
Parameters

Click the ellipsis icon in the field and add a variable for each parameter you want to send to the spawned script. Enter one variable per line in the editor window. Use meaningful variable names. Variable names do not have to match the name of the corresponding variable used in the spawned script.

Parameters that are passed into a script appear in that script's trace output in the Begin action.

Result Branch Conditions

Result branch conditions allow you to create branches in your script to handle different outcomes when an action executes.

Condition

Description

Default

Path taken unless the script meets a condition that requires it to take one of the other branches. It is also taken if the action's other branches are not defined.

OnError

Path taken when the action fails to execute properly. For example, when there is an unexpected problem such as poor connectivity, syntax errors, and so on. The _ERR variable, with a single underscore character, should be populated with a condensed explanation of the problem.

Script Example

This example is not a complete script. Additional scripting work is required to use this action.

In the main script below (shown top), when the script is triggered, the Runsub action immediately triggers the subscript (shown bottom). In the subscript, Voiceparams sets the Text-to-Speech settings, and the Hours action sets branches for open, closed, and holiday to three different Return actions. When the subscript is finished, the values in the ReturnValues property (in the Return action) are stored in the ReturnVariable field (Runsub action in the main script). The Case action then sets the open, closed, and holiday branches as appropriate.

Main Script

An example script, showing Studio actions with arrows connecting them. Each action has a label beneath it to indicate what the action does in the script.

Would you like to download this script?

Subscript

An example script, showing Studio actions with arrows connecting them. Each action has a label beneath it to indicate what the action does in the script.

The three Return actions provide values in the ReturnValue property so the Case action in the main script can determine which branch to follow.

Would you like to download this script?