SNIPPET

Allows you to add custom code to your script.

Dependencies

  • Code used in this action must be written in Snippet, an in-house scripting language developed by NICE CXone. The Studio technical reference guide provides detailed information about scripting in snippets.
  • Attributes of dynamic data objects cannot be named __type (with two underscores). This word is reserved for use when parsing JSON from dynamic objects.
  • You can make API calls using the Snippet action. The maximum response size is 32 KB. This is consistent with the response size limit in the REST API action.  The limit is strictly enforced to prevent cluster instability and outages. If you can, use the REST API action instead. It has the same limit, but can handle a heavier load. If you must use the SNIPPET action, follow these tips to reduce the size of the returned data: 
    • Filter the data in the API response. For example, if you're using the NICE reporting API to get contacts, you can filter the results by the startDate and endDate of the contact. This API call also allows you to return and limit a top count of items. Refer to the API documentation that came with your script integration to determine what filtering you can use.

    • Update the API request to return only the data you need. For example, if you're using the NICE reporting API to get contacts, you can use the contactId or agentId fields to return only relevant data. Refer to the API documentation that came with your script integration to determine what data limits you can use.

    • If you cannot do either of the previous options, build middleware.

  • The maximum size of arrays in Studio is 63 million elements. Exceeding this array size results in the following error in the __err variable in a script traceArray index out of bounds. The current array index ([index]) exceeds the maximum allowed index (63000000). When the array size is exceeded, the script takes the SNIPPET action's Error branch. If the Error branch is not connected, the script continues to run, but without the array information. You can configure scripts to notify you when the maximum array size has been exceeded by adding an EMAIL action to the SNIPPET action's Error branch. Finally, you can add logic in the Error branch to continue to the script. Note that it will continue without the array information.

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

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.

Data

Contains the custom code added in the Snippet editor window. This can include multiple ASSIGN and DYNAMICcommands, assorted flow control statements, and built-in and user-defined functions.

MaxStringSize

Sets the maximum string size for all commands in the Data property. Options are: Limit2K, Limit4K, Limit8K, Limit16K, Limit32K. This limit applies to integration responses with Rest APIs and SOAP.

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.

Tips & Tricks

Snippet Editor Window

The Snippet editor window opens when you double-click on a Snippet action.

The Snippet editor window in the Snippet action has two tabs. Both tabs allow you to create the same kinds of code. You can switch back and forth between the tabs and edit your code in either place. The tabs are: 

  • The Text View tab. This is a free-form text field where you can type your code out manually.
  • The Tree View tab. This is a graphical interface you can use to build your code. This tab has a list you can select keywords from to add statements to the snippet.

Script Example

This is an example to show how this action can be used in scripts. It is not intended to be a complete script. Additional scripting may be required.

In this simple example, the code in the Snippet is used to test whether a prospect can be created using information from a third-party system.

A script with two SNIPPET actions.

Download this script.