SNIPPET

Esta página de ayuda es para Studio. Esta información también está disponible para Desktop Studio.

Le permite agregar código personalizado a su script.

Making REST API calls from a SNIPPET action is strongly discouraged. Instead, use the REST API action or Integration Hub. If your API is SOAP or returns XML, review the recommendations for how to minimize the impact on your system from making API calls from SNIPPET.

Las Dependencias

  • Code used in this action must be written in Snippet, an in-house scripting language developed for 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. However, this is not the recommended method of making API calls in your scripts. If you do make them in this way, be sure to understand the risks and best practices.
  • El tamaño máximo de las matrices en Studio es de 63 millones de elementos. Exceder este tamaño de matriz genera el siguiente error en la variable __err en un seguimiento de script: Índice de matriz fuera de límites. El índice de la matriz actual ([índice]) excede el índice máximo permitido (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.
  • The maximum response size in NiCE CXone is 32 KB. The limit is strictly enforced to prevent cluster instability and outages. Studio enforces this limit when saving the script, but Desktop Studio does not. If you can, use the REST API action or Integration Hub instead of the SNIPPET action to make API calls. They have 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.

    • Build middleware: If you cannot do either of the previous options, build middleware that does filtering based on custom criteria you define. If you do this, ensure that your middleware does not add latency to the call.

  • Every FOR, FOREACH, or REPEAT loop within a SNIPPET is protected by a 500 ms time limit. If a loop exceeds this limit, the SNIPPET action takes the error branch with the error Too much time has elapsed. This prevents the use of excessive system resources for runaway loops. The 500 ms time limit applies only to script-side work, including assignments, arithmetic, conditions, array access, and so on. It does not apply to the end-to-end running of the snippet code. For example, time spent waiting for an external system such as a REST API or database call does not count against this limit.

Tipos de secuencias de comandos compatibles

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

Generic

Email Chat Phone Voicemail Work Item SMS Digital

Propiedades de Entrada

Estas propiedades definen los datos que utiliza la acción al ejecutarse.

Las propiedad

Descripción

Add Caption

Ingrese una frase corta que identifique de forma única esta acción en el script. La leyenda aparece en el lienzo del script debajo del ícono de acción.

Datos

Contiene el código personalizado que se agregó en la ventana Snippet editor. Esto puede incluir varios comandos ASSIGN y DYNAMIC, declaraciones de control de flujo distintas y funciones integradas y definidas por el usuario.

Tamaño máximo de cadena

Define el tamaño máximo de cadena para todos los comandos en la propiedad Data. Las opciones son: Limit2K, Limit4K, Limit8K, Limit16K, Limit32K. Se aplica este límite a las respuestas de integración con las Rest API y SOAP.

Condiciones de rama de Resultado

Las condiciones de las ramas de resultados le permiten crear ramas en su script para manejar diferentes resultados cuando se ejecute una acción.

Condición

Descripción

Default

Recorrido a menos que el script cumple una condición que requiere uno de los otros poderes. También se considera si no están definidas las demás ramas de la acción.

Error

Ruta tomada cuando la acción no se ejecuta correctamente. Por ejemplo, cuando haya un problema inesperado como una mala conectividad, errores de sintaxis, etc. La variable _ERR, con un único carácter de subrayado, debe llenarse con una explicación condensada del problema.

Consejos y trucos

Ventana del Editor de Snippet

La ventana del editor de Snippet se abre cuando selecciona una acción Snippet y hace clic en Abrir editor en las propiedades de la acción. También puede hacer clic en la ventana Icon of a rectangle with a horizontal line across it. en medio de la acción cuando esta se encuentra en el lienzo del script.

Ejemplo de Script

Este es un ejemplo para demostrar cómo se puede utilizar esta acción en los scripts. No pretende ser un script completo. Es posible que se requiera programación adicional.

En este ejemplo simple, las acciones Snippet contienen declaraciones de objetos de datos dinámicos y otras variables utilizadas en el script. El Snippet con el título Analizar la transcripción contiene código que verifica si la transcripción corresponde a un mensaje de voz. Si es un mensaje de voz, el script copia el cuerpo del mensaje de la transcripción a una variable. La variable que contiene el cuerpo del mensaje se pasa a la acción PLAY, que lee el mensaje mediante texto a vozClosed Permite a los usuarios ingresar avisos grabados como texto y utilizar una voz generada por computadora para reproducir el contenido..

Image of a script with several SNIPPET actions.

Descargue este script.