Post Message is not working in External Site for Einstein Chat Bot

183 Views Asked by At

I am using below code in my LWC for using in Einstein Chat Bot. I am getting proper response in Community and Chat bot preview mode but not in External Site. Any code I need to add in Embedded Service Deployment settings to make that work? I am not finding any result...

` handleOk(event)
    {
        this.surveyDisabled = true;
        this.dispatchEvent(new CustomEvent('postmessage',{
        detail: 'lwc:hide:' + this.checkValue.join(';')
        }));
    }`

I haven't found any code snippet to try it on External Site.

1

There are 1 best solutions below

1
FayaX On

have you added this script to the external page?

<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
    var payload = event.data;

    if(payload && payload.type === "chasitor.sendMessage") {
        embedded_svc.postMessage("chasitor.sendMessage", payload.message);
    }
};
</script>