Loading
Ongoing maintenance for Salesforce HelpRead More
Feature degradation | Gmail Email delivery failureRead More
Service
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create a Custom Component to Trigger an Action

          Create a Custom Component to Trigger an Action

          To subscribe to intelligence signals defined in your telephony system and trigger actions based on those signals, create Aura custom components in Salesforce. For example, create an action that recommends that the support rep offer a discount if the customer asks to cancel the service due to a poor customer experience. To create a custom component, pass the detected signal to a Recommendation Strategy flow and link the flow to the Einstein Next Best Action component in a Lightning page.

          Required Editions

          View supported editions.

          Let’s look at an example where you create a custom component called Voice Intelligence Tester (ConversationIntelligenceTester.cmp).

          1. Create the custom component. This custom component subscribes to the Salesforce Voice Aura Toolkit API.
            <aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
              <!-- Subscribe to the Salesforce 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>
            
            Important
            Important When you create a custom component, Conversation Intelligence supports using only Salesforce Voice Aura Toolkit API, not Salesforce Voice Lightning Web Component Toolkit API.
          2. Create the controller resource (ConversationIntelligenceTesterController.js). This resource subscribes and listens to signals defined in your telephony system rules.
            
            ({
              onInit: function(cmp, event, helper) {
                helper.subscribeToVoiceToolkit(cmp);
              },
            
              onDestroy: function(cmp, event, helper) {
                helper.unsubscribeFromVoiceToolkit(cmp);
              }
            })
          3. Create the helper resource (ConversationIntelligenceTesterHelper.js). This resource listens for the new Toolkit API conversation event, INTELLIGENCE_SIGNAL, processes each detected signal, and triggers the next best action (NBA) based on the category name defined in your telephony system rule. In this example, it triggers the next best action if the category name is CustomerAttritionRiskWithNegSentiment.
            Important
            Important Ensure that the payload attribute name of the updateNextBestActions method matches the input variable label in the Recommendation Strategy flow. In this example, the attribute is category.
            ({
              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);
              }
            })
            
           
          Loading
          Salesforce Help | Article