we have a requirement to disconnect the chat interaction when the client ends the chat session.
i tried using PATCH conversations/chat while setting the state to "disconnected", which sort of worked? it got the chat interaction disconnected, but it didn't allow the agent to assign a wrap up code.
is there a way to just trigger the disconnect button and still allow the wrap up to pop up so that the agent code select the appropriate wrap up code?
How do you integrate PureCloud softphone with Salesforce, is it using Embedded Framework ? We're using Embedded Framework hook in Salesforce using Apex (visualforce & class), put all javascript & html there.
If you using embedded framework, you can disconnect chat with javascript (no need API), put a button in salesforce page, and call following function. Need to use postmessage function as embedded framework is iframe inside Salesforce page.
function updateInteractionState(event) {
var lastInteractionPayload = JSON.parse(document.getElementById("interactionSubscriptionPayload").value);
var interactionId;
if (lastInteractionPayload.data.interaction.old){
interactionId = lastInteractionPayload.data.interaction.old.id;
}else {
interactionId = lastInteractionPayload.data.interaction.id;
}
let payload = {
action: event.target.outerText,
id: interactionId
};
var jsonClick =JSON.stringify({type: 'updateInteractionState', data: payload});
const frameArr1 = window.top.frames;
for (let i = 0; i < frameArr1.length; i++) {
postMessageRecursive(frameArr1[i], jsonClick, "*");
}
}
function postMessageRecursive(iframe, msg, targetOrigin) {
iframe.postMessage(msg, targetOrigin);
if (iframe.frames.length > 0) {
for (let i = 0; i < iframe.frames.length; i++) {
postMessageRecursive(iframe.frames[i], msg, targetOrigin);
}
}
}