The Salesforce Messaging For Web SDK can be used to connect your users with agents in Salesforce chat.
To avoid the user having to repeat themselves, the context of what happened in the assistant can be passed over to the agent in the Salesforce chat.
Get the Salesforce Chat Code
Retrieve the Salesforce embedded chat code snippet. For more information, refer to the Salesforce article Configure a Messaging for Web Deployment.
Get the Mavenoid Embed Code
Get the Mavenoid embed code. Refer to our help center article Web Assistant Touchpoint.
Add an external script to the Mavenoid embed code
Add the Salesforce chat snippet as an external script in Mavenoid. Refer to Code Template for details.
Add the External Script node to the canvas
Whenever you want the Salesforce chat to open, add the external script node that calls upon the external script added in the above step.
For more details on how to set up external scripts for chat handovers, see External Scripts for Chat Handovers.
mavenoid.push({
event: "assistant-mount",
clientId: "YOUR_MAVENOID_CLIENT_ID",
externalScripts: {
async openSalesforceChat(input) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "YOUR_SALESFORCE_MESSAGING_SCRIPT_SRC";
document.body.appendChild(script);
script.onload = function () {
// Initalize Messaging for Web
embeddedservice_bootstrap.settings.language = "en_US";
embeddedservice_bootstrap.init(/* YOUR_SALESFORCE_MESSAGING_CONFIG_PARAMETERS*/);
// Pass context to the agent in Salesforce
embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({});
// Open the Messaging widget
embeddedservice_bootstrap.utilAPI.launchChat();
};
// Wait for Salesforce chat to open before declaring the chat handover a success
return new Promise((resolve) => {
window.addEventListener("onEmbeddedMessagingReady", () => {
mavenoid.push({ event: "assistant-unmount" });
});
resolve({
formData: [
{
id: "result",
value: { type: "string", value: "ok" },
},
],
});
});
},
},
});