SNIPPET

允许您向脚本中添加自定义代码。

Dependencies

  • 此操作中使用的代码必须使用 Snippet 编写,这是一种由 NICE CXone 开发的内部脚本语言。Studio 技术参考指南提供了有关在代码片段中编写脚本的详细信息。
  • 动态数据对象的属性不得命名为 __type (带两个下划线)。这个词是在从动态对象解析 JSON 时保留的。
  • 您可以使用Snippet操作进行 API 调用。最大响应大小为 32 KB。这与 REST API 操作中的响应大小限制一致。严格执行该限制是为了防止群集不稳定和中断。如果可以,请改用 REST API action。它具有相同的限制,但可以处理更繁重的负载。如果您必须使用 SNIPPET 操作,请按照以下提示减小返回数据的大小:
    • 筛选 API 响应中的数据。例如,如果使用 NICE 报告 API 获取联系人,则可以按联系人的 startDateendDate 筛选结果。此 API 调用还允许返回并限制最大项目数。请参阅脚本集成随附的 API 文档,以确定可以使用的筛选。

    • 更新 API 请求,仅返回需要的数据。例如,如果使用 NICE 报告 API 获取联系人,则可以使用 contactIdagentId 字段仅返回相关数据。请参阅脚本集成随附的 API 文档,以确定可以使用的数据限制。

    • 如果无法执行上述任一选项,请构建中间件。

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.

通用

电子邮件 聊天 电话 语音信箱 工作项目 短信 数字

Input Properties

这些属性定义操作在执行时使用的数据。

属性

说明

Caption

输入在脚本中唯一标识此操作的短语。标题显示在脚本画布上的操作图标下方。The default is the action name.

Data

包含在 Snippet Editor 窗口中添加的自定义代码。其中可以包括多条 ASSIGNDYNAMIC 命令、各种流量控制语句以及内置和用户定义的函数

MaxStringSize

设置 Data 属性中所有命令的最大字符串大小。选项包括:Limit2KLimit4KLimit8KLimit16KLimit32K。此限制适用于 Rest API 和 SOAP 的集成响应。

Result Branch Conditions

结果分支条件允许您在脚本中创建分支,以在执行操作时处理不同的结果。

条件

说明

Default

除了脚本满足条件要求其接受其他分支的情况之外,所要采用的路径。如果未定义操作的其他分支,也会执行此操作。

OnError

操作无法正确执行时所采用的路径。例如,出现连接不良、语法错误等意外问题时。_ERR 变量以单个下划线字符填充,应包含对问题的简要解释。

Tips & Tricks

Snippet Editor Window

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

Snippet Editor操作中的窗口Snippet有两个选项卡。这两个选项卡都允许您创建相同类型的代码。您可以在选项卡之间来回切换并在任一位置编辑代码。这些选项卡分别是:

  • 文本视图选项卡。这是一个自由格式的文本字段,您可以在其中手动输入代码。
  • 树视图选项卡。这是一个可用于构建代码的图形界面。此选项卡有一个列表,您可以从中选择关键字以将语句添加到代码片段。

Script Example

此示例并非完整的脚本。要使用此操作,需要额外的脚本编写工作。

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.