Introduction
With the Unbabel for Chat (formerly Live Agent) 2.4 package release update we allow sending outbound messages using custom events with our component.
Requirements
Please make sure you have:
- Unbabel for Chat installed on your Salesforce Org with version 2.4 or later.
- Knowledge on the Salesforce Aura framework.
- Development knowledge in order to implement this solution.
Steps
1 - Add an Aura register event to your aura component.cmp with the following parameters:
-
- name="unbabelChat"
- type="unbabelli:unbabelChat"
- access="global"
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId">
<aura:registerEvent name="unbabelChat" type="unbabelli:unbabelChat" access="global" />
<button onclick="{!c.sendEvent}">Send</button>
</aura:component>
(On this code snippet we show an aura component with the register event and a button to call the event)
2- Create a controller.js function to send the Unbabel event
({
sendEvent : function(component, event, helper) {
console.log('click');
var appEvent = $A.get("e.unbabelli:unbabelChat");
appEvent.setParams({
recordId: "5705E000000SHgyQAG",
method: 'sendMessage',
params: {
message: "Hello there!!!",
publish: true
}
});
appEvent.fire();
}
})
3 - Set the parameters of the event where you pass:
-
- recordId: the id of the chat conversation
- method: “sendMessage”, currently is the only supported method
- params:
- message: string, the message you want to send
- publish: boolean, if true the message will show to the agent and to the client, if false the message will just show to the agent
4 - After you have this deployed, and tested the flow, the sent message should show on our component.
Comments
0 comments
Please sign in to leave a comment.