diff --git a/app/javascript/packs/sdk.js b/app/javascript/packs/sdk.js index ab02f1f3a..d666b864b 100755 --- a/app/javascript/packs/sdk.js +++ b/app/javascript/packs/sdk.js @@ -40,8 +40,8 @@ const runSDK = ({ baseUrl, websiteToken }) => { launcherTitle: chatwootSettings.launcherTitle || '', showPopoutButton: chatwootSettings.showPopoutButton || false, - toggle() { - IFrameHelper.events.toggleBubble(); + toggle(state) { + IFrameHelper.events.toggleBubble(state); }, setUser(identifier, user) { diff --git a/app/javascript/sdk/IFrameHelper.js b/app/javascript/sdk/IFrameHelper.js index 5fcf215c0..098171fe5 100644 --- a/app/javascript/sdk/IFrameHelper.js +++ b/app/javascript/sdk/IFrameHelper.js @@ -137,8 +137,15 @@ export const IFrameHelper = { setBubbleText(window.$chatwoot.launcherTitle || message.label); }, - toggleBubble: () => { - onBubbleClick(); + toggleBubble: state => { + let bubbleState = {}; + if (state === 'open') { + bubbleState.toggleValue = true; + } else if (state === 'close') { + bubbleState.toggleValue = false; + } + + onBubbleClick(bubbleState); }, onBubbleToggle: isOpen => {