Spawn Scripts

Spawning a script allows you to run a script manually. It's also used to start a script from other scripts or external processes. You can also use it to test a script. When testing, it can be used together with script traces.

To test scripts, you can spawn scripts from Studio using the trace option.

To start scripts from other scripts or processes:

  • Use the SPAWN action in the calling script.
  • Using the POST /scripts/start An icon of a square with an arrow  pointing from the center out to the upper right corner. API. This is the recommended solution to spawn a script from any external process.

Business units can run a maximum of 15,000 scripts, unless otherwise configured. When that limit is reached, additional scripts cannot be started or spawned using any of the methods described on this page until one or more scripts stop running.

Script Parameters

Script parameters allow data to be passed into scripts. The data might come from other scripts, including system scripts, or from external sources such as CRMsClosed Third-party systems that manage such things as contacts, sales information, support details, and case histories. or APIs. It's passed into the scripts in pXvariables, p1 through pN, where N is the maximum number of parameters supported by the spawn method. You can specify the data to be passed into the script when you spawn a script using any of the options listed in the previous section.

If you want to change the names of the parameter variables, you can configure the Begin action in the spawned script with new names. When the script processes the BEGIN action, the pX variables are converted to the new names. If you don't specify new names, the variables retain the pX names.

When data is passed into a script, you can see it in a trace. Select the BEGIN action to see the parameter variables in the trace output variables list. If you've configured the BEGIN action with new variable names, select the action that comes after BEGIN in the script trace to see them. Parameter variables are only present if they hold a value.

Custom parameters: 

  • Support a maximum of: 
    • 32 KB per value when spawned using the SPAWN action.
    • 32 KB total for all parameters, including the pipe delimiters, when spawned by API.
  • Support variable substitution. Enter the variable name in curly brackets ( { } ).
  • Support 1-20 parameters when spawning by the SPAWN action or API.
  • Do not support dynamic data objects. Objects must be converted to a JSON string first.

Comparison of Studio Actions

There are three Studio actions that start a new script from the current script. However, there are some differences between them: 

  • Runscript: When  triggers another script, it doesn't return to the first script from the second script.
  • Runsub: When triggers a subscript, the script can return to the first script, as long as the subscript has a action. The action provides a value back to the action when the subscript is finished.
  • SPAWN: Starts a second script that runs in parallel to the first script. Spawned scripts cannot pass data back to the first script unless you include a action in the spawned script.

Spawn from Another Script Using the SPAWN Action

If you don't need to pass parameter values to the child script, all you need to do is add and configure the SPAWN action in the parent script. If you need to pass parameters, you need to make the following configurations:

  • Make the following changes in the parent script:
    • Place the SPAWN action at the point where you want to spawn the child script. Configure the Parameters property in the SPAWN action with any values you need to pass to the child script. Values are passed in variables p1 to p9.
    • Configure the other properties of the SPAWN action.
  • Make the following changes in the child script: 

    • Configure the Parameters property in the action to change the name of the custom parameter variables. If you do nothing, custom parameter values remain in the variables.
    • If you need to pass values back to the parent script or calling application, add and configure a action.

Spawn a Script by API

Use the POST /scripts/start An icon of a square with an arrow  pointing from the center out to the upper right corner. API to spawn a script.

When using this API, it's important to note that: 

  • The following parameters are required: 
    • skillId: The value must be an integer when sending as JSON, but not if sending as query parameters. Skills must: 
        • Be active.
        • Match the script media type. For example, phone scripts must correlate with phone call skills. You can find the skill type on the Details tab of a skill. Scripts with the Generic type work with any active skill.
    • scriptId or scriptPath: Using scriptPath is recommended. The script ID changes every time changes to the script are saved, so it must be updated in the parameter.

  • You can include up to 20 parameters.
  • Parameters must be sent in a pipe-delimited list.
  • The API supports a maximum of 32 KB for all parameters, including the pipe delimiters.
  • Parameters cannot include pipe characters unless they are delimiters.
  • If sending the request as JSON, reserved characters must be properly escaped.
  • If sending the request by URL query parameters, the parameters must be URL-encoded.