SNIPPET

This help page is for CXone Studio. This information is also available for Desktop Studio.

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.

Supported Script Types

A square with a line branching from it that goes to three other squares.

Generic

Email Chat Phone Voicemail Work Item SMS Digital

Input Properties

These properties define data that the action uses when executing.

Property

Description

Add Caption

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

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.

Max String Size

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.

Error

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 select a Snippet action and click Open Editor in the action properties.

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.