创建自定义组件以触发操作
要订阅电话系统中定义的智能信号和基于这些信号触发操作,请在 Salesforce 中创建 Aura 自定义组件。例如,创建一个操作,建议支持代表在客户因客户体验不佳而要求取消服务时提供折扣。要创建自定义组件,将检测到的信号传递给推荐策略流,并将该流链接到 Lightning 页面中的 Einstein Next Best Action 组件。
所需的 Edition
| 查看支持版本。 |
让我们看一个例子,其中创建了一个名为 (ConversationIntelligenceTester.cmp) 的自定义组件。
-
创建自定义组件。此自定义组件订阅 Service Cloud 语音 Aura 工具包 API。
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" > <!-- Subscribe to Service Cloud Voice Toolkit API --> <force:serviceCloudVoiceToolkitApi aura:id="voiceToolkitApi"/> <force:recordData recordId="{!v.recordId}" layoutType="FULL" targetFields="{!v.record}" fields="VendorCallKey"/> <aura:handler name="init" value="{!this}" action="{!c.onInit}"/> <aura:handler name="destroy" value="{!this}" action="{!c.onDestroy}"/> <!-- Get record data --> <aura:attribute name="record" type="Object"/> </aura:component>
重要 在创建自定义组件时,对话智能仅支持使用 Service Cloud Voice Aura 工具包 API,不支持 Service Cloud 语音 Lightning Web 组件工作包 API。 -
创建控制器资源 (ConversationIntelligenceTesterController.js)。此资源会订阅并监听电话系统规则中定义的信号。
({ onInit: function(cmp, event, helper) { helper.subscribeToVoiceToolkit(cmp); }, onDestroy: function(cmp, event, helper) { helper.unsubscribeFromVoiceToolkit(cmp); } }) -
创建助手资源 (ConversationIntelligenceTesterHelper.js)。此资源会根据电话系统规则定义的类别名称,监听新工具包 API 对话事件 INTELligENCE_SIGNAL,处理检测到的每个信号,并触发 Next Best Action (NBA)。在本示例中,如果类别名称是 CustomerAttritionRiskWithNegSentiment,将触发 Next Best Action。
重要 确保 updateNextBestActions 方法的有效负载属性名称与建议策略流中的输入变量标签相匹配。在此示例中,属性是类别。({ subscribeToVoiceToolkit: function(cmp) { // Subscribe to the INTELLIGENCE_SIGNAL event type cmp._signalEventListener = $A.getCallback(this.signalEventListener.bind(this, cmp)); cmp.find('voiceToolkitApi').addConversationEventListener('INTELLIGENCE_SIGNAL', cmp._signalEventListener); }, unsubscribeFromVoiceToolkit: function(cmp) { cmp.find('voiceToolkitApi').removeConversationEventListener('INTELLIGENCE_SIGNAL', cmp._signalEventListener); }, signalEventListener: function(cmp, signal) { this.processIntent(cmp, signal); }, processIntent: function(cmp, signal) { var data = cmp.get('v.data'); var events = signal.detail.events; for (var i = 0; i < events.length; i++) { var category = {}; category.category = events[i].value; category.service = events[i].service // Filter the signal and decide the action // CustomerAttritionRiskWithNegSentiment is a category value // defined in the Amazon Connect rule if (events[i].value === 'CustomerAttritionRiskWithNegSentiment') { this.triggerNBA(cmp, events[i].value); } } }, triggerNBA: function(cmp, value) { var params ={ category: [value] }; cmp.find('voiceToolkitApi').updateNextBestActions(cmp.get('v.recordId'), params); } })
本文章是否解决您的问题?
请与我们共享您的想法,以便我们进行改进!

