Colatabajonies / Chat-Lightning-Web-Component-Pack

29 stars 22 forks source link

The window.postMessage to send a chasitor event doesn't work. #2

Closed erocheleau closed 2 years ago

erocheleau commented 4 years ago

On my community or inside the bot preview, any component that are "replacing" the customer's input, for example the date picker, the survery, etc.

They all try to send a response to the bot back with

window.postMessage({ message: dateValue, type: "chasitor.sendMessage" }, window.parent.location.href );

I see the event being fired, but nothing happens and the bot doesn't receive the customer's message so it just sits there waiting for an input.

wilsonwong13 commented 4 years ago

Is there any documentation how window.postMessage( { message: dateValue, type: "chasitor.sendMessage" }, window.parent.location.href ); works? I can't find anything at the moment

erocheleau commented 4 years ago

Me neither, looks like a spoof of what the actual chat window receives as an event when the customer sends a chat message?

wilsonwong13 commented 4 years ago

@erocheleau Have you looked at the user guide yet? https://quip.com/WM7AA3tXRsaf

erocheleau commented 4 years ago

I have found it afterwards yes, my bad.

But is there no other way to support this? As someone who wants to distribute a managed package using this feature, it is not really realistic to ask every client to copy a JS snippet in the header of their community.

You can close this as it isn't really related to this package anymore, but perhaps you could add that quip link to the readme?

forcePanda commented 3 years ago

Is there any other way to post the message as chasitor from the LWC to the bot? I don't want to do: window.postMessage({ message: dateValue, type: "chasitor.sendMessage" }, window.parent.location.href );

And use the script in the community page header.

erocheleau commented 2 years ago

This issue was resolved after reading the documentation :)