Colatabajonies / Chat-Lightning-Web-Component-Pack

29 stars 22 forks source link

Screen flow without community #7

Closed bartyzelm closed 3 years ago

bartyzelm commented 3 years ago

My organization is not using community, and chat is exposed on company website. Is there a way to use Screen flow in chat in this setup ? I'm asking as in the documentation there is an information: "Ensure that you followed the community page steps above to have your flowcomponent page setup prior to using the flow component." which is not an option.

mauricioruizintellect commented 3 years ago

Hi @bartyzelm. I did the following steps and it works :

  1. In the runflowController I changed this:

const parentOrigin = document.referrer; parent.postMessage( { message: 'lwc:hide:' + JSON.stringify(outputVariables), type: 'flow.finished' }, parentOrigin);

  1. On my site , I put this code (The same code for the community): window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { var payload = event.data; console.log('payload 1 '+payload); if(payload && payload.type === "chasitor.sendMessage") { console.log('payload 2 '+payload); embedded_svc.postMessage("chasitor.sendMessage", payload.message); } }; above the code generated by salesforce
bartyzelm commented 3 years ago

@mauricioruizintellect thank you very much :) we will try that :)

waniu commented 3 years ago

Hi @mauricioruizintellect Is there any reason why this component was written in aura?

mauricioruizintellect commented 3 years ago

Hi @mauricioruizintellect Is there any reason why this component was written in aura? I think the aura component has the "lightning:flow" property and lwc does not.

waniu commented 3 years ago

@mauricioruizintellect Yeah, you are right. I'm trying to understand how did you managed to make aura collaborate with LWC. If LWC is main component how do you want to run aura component in chat? Only LWC has possibility to override 'original chat messages' (extends BaseChatMessage).