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. Reference material for using Snippet is available in the Studio online help.
- 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.
Supported Script Types
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Generic | Chat | Phone | Voicemail | Work Item | SMS | Digital |
Properties
Property | Details |
---|---|
Data |
Contains the custom code added in the Snippet editor window. This can include multiple ASSIGN commands to create variables, DYNAMIC commands to create dynamic data objects, assorted flow control keywords, 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. |
Branches
Branch | Details |
---|---|
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 (for example, poor connectivity, syntax errors, and so forth). The _ERR variable (with a single underscore character) should be populated with a condensed explanation of the problem. |
Tips & Tricks
- Use the asjson() method in a Snippet action and store the resulting JSON in a string variable. Use the string variable in the properties of other Studio actions when you need to pass the JSON data. This approach avoids the possibility of validation errors when saving the script.
- If you're tuning an ASR-enabled IVR system, there is a set of parameters you can use in snippets.
- The Snippet language provides keyword commands that allow you to declare variables and objects, create loops and iterative statements, and more.
- Studio has built-in functions that you can use in your scripts.
- You can create your own custom functions to use in snippets.
- You can debug snippet code in the Snippet editor window.
Snippet Editor Window
The Snippet window opens when you double-click on a Snippet action.
Phone Script Example Using Snippets
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.