You need to sign in to do that
Don't have an account?
Sam Sam 85
Embedded Service - Embedded Web Chat - Intercept User Sent Message
Hello everyone,
I am currently stuck trying to figure out how to do the following:
Is there a way I could intercept the user sent message on client-side (before it goes to the bot) and then send to the bot my own custom message, all in javascript?
For example:
1. User sends a message "Hello".
2. My client-side javascript, intercepts the user sent message.
3. In javascript, customize the message and then send the custom message to the bot. In this example, I send to the bot "Hello, world!!!".
Thank you for all your help.
HTML Code:
Javscript Code:
I am currently stuck trying to figure out how to do the following:
Is there a way I could intercept the user sent message on client-side (before it goes to the bot) and then send to the bot my own custom message, all in javascript?
For example:
1. User sends a message "Hello".
2. My client-side javascript, intercepts the user sent message.
3. In javascript, customize the message and then send the custom message to the bot. In this example, I send to the bot "Hello, world!!!".
Thank you for all your help.
HTML Code:
<div id="divContainer"> <img id="imgChatBubble" src="..." /> </div>
Javscript Code:
var initESW = function (gslbBaseURL) { embedded_svc.settings.displayHelpButton = false; embedded_svc.settings.language = ''; embedded_svc.settings.enabledFeatures = ['LiveAgent']; embedded_svc.settings.entryFeature = 'LiveAgent'; embedded_svc.settings.widgetHeight = "90%"; embedded_svc.init( '...', '...', gslbBaseURL, '...', '...', { baseLiveAgentContentURL: '...', deploymentId: '...', buttonId: '...', baseLiveAgentURL: '...', eswLiveAgentDevName: '...', isOfflineSupportEnabled: true } ); }; if (!window.embedded_svc) { var s = document.createElement('script'); s.setAttribute('src', '...'); s.onload = function () { initESW(null); }; document.body.appendChild(s); } else { initESW('https://service.force.com'); } function setupOnChasitorMessageEventHandler() { // onChasitorMessage event fired when user sends a message. // This event handler will handle the fired onChasitorMessage event. embedded_svc.addEventHandler("onChasitorMessage", function (data) { if (true) { } }); } setupOnChasitorMessageEventHandler();
You can achieve this using the Lightning Web Component.
https://www.infallibletechie.com/2021/12/how-to-interceptmodify-chat-message-in.html