显示一个通知,可用于通知代理有关传入对话的信息。
Syntax
Microsoft.CIFramework.notifyEvent(input, correlationId, cancellationToken).then(successCallback, errorCallback);
参数
| Name | 类型 | 必选 | Description |
|---|---|---|---|
| 输入 | JSON 对象 | 是的 | String |
| correlationId | GUID | 否 | 用于将所有相关 API 调用分组在一起以进行诊断遥测。 |
| 取消令牌 | String | 否 | 是方法用于 cancelEvent 取消有关传入对话的通知的唯一字符串。 |
| success回调 | 功能 | 否 | 请求成功时要调用的函数。 回调成功后,响应对象将包含有关客户是接受还是拒绝对话的信息。 |
| errorCallback | 功能 | 否 | 请求失败时要调用的函数。 |
回调函数详细信息
以下对象被传递到 and successCallbackerrorCallback 函数中。
successCallback 函数
示例 JSON 对象:
{
"value": {"actionName" : "Accept",
"responseReason" : "Accept"}
}
参数
| actionName | 响应原因 | Description |
|---|---|---|
| Accept | Accept | 当用户接受通知时 |
| Accept | 自动接受 | 默认情况下,通过通知模板接受通知 |
| 拒绝 | 拒绝dBy代理 | 当用户拒绝通知时 |
| 拒绝 | NotificationQueueLimitExceeded (通知队列限制已超出) | 如果队列中的限制超过 10 个通知,则通知将被拒绝 |
| 拒绝 | NotificationQueueTimeLimitExceeded (通知队列时间限制已超出) | 当队列中的通知超过配置的超时时间时 |
| 超时 | 显示超时 | 当用户在超时期限内未响应通知时 |
errorCallback 函数
示例 JSON 对象:
{
"message" : "<error details>",
"msdyn_name" : "NotifyEvent"
}
参数
| 消息 | Description |
|---|---|
| 通知模板NotFoundError | 找不到指定的模板名称时 |
| 拒绝客户端错误后 | 发生未知异常(当Platform API调用失败或缺少某些输入参数时发生) |
Example
var canceltoken = "cancellationtoken"+ Math.ceil(Math.random() * 100000 + 100000).toString();
var input = {
templateName: "msdyn_chat_incoming_unauthenticated",
// unique name of the configured template
templateParameters: {
},
// unique random token, to identify the notification during cancelEvent call
cancellationToken: canceltoken
}
Microsoft.CIFramework.notifyEvent(input).then(
function success(result) {
console.log(result);
// Perform operations
},
function (error) {
console.log(error.message);
// Handle error conditions
}
);