APIs & Integrations

SAncliff
Teilnehmer/-in | Diamond Partner
Teilnehmer/-in | Diamond Partner

Chatflow embedded through iframe

lösung

Hi all,

I'm trying to get the chatflow embedded on a landing page using an iframe, which I've managed to get to partially work using the below code:

 

 

 

 

<div style="width: 600x; height: 530px;"><div class="shadow"></div><iframe src="https://app.hubspot.com/conversations-visitor/2847527/threads/utk/2d64ca96e67045ada23e17022b81e7e3?uuid=b82cd5287a564b76bee4ee7286a6b200&amp;mobile=false&amp;mobileSafari=false&amp;hideWelcomeMessage=false&amp;hstc=216559305.2031e080e10c81345f36bd078f70053a.1627467156034.1627467156034.1627467156034.1&amp;domain=silverbug.it&amp;inApp53=false&amp;messagesUtk=2d64ca96e67045ada23e17022b81e7e3&amp;url=https%3A%2F%2Fwww.silverbug.it%2Fcyber-risk-calculator&amp;inline=false&amp;isFullscreen=false&amp;globalCookieOptOut=no&amp;isFirstVisitorSession=true&amp;isAttachmentDisabled=true&amp;enableWidgetCookieBanner=false&amp;isInCMS=true&amp;hubspotUtk=2031e080e10c81345f36bd078f70053a" width="400" height="600" align="centre" frameborder="0" class="LivePreview__PreviewIFrame-sc-10lc3a6-0 GGqrS"></iframe></div>

 

 

 

 


The only problem is, the above code has a fixed UUID "uuid=b82cd5287a564b76bee4ee7286a6b200"
However, the popup chatflow will dynamically apply a UUID, meaning the only way I can get this to work is by changing the UUID through Inspect by copying it from the popup chatflow iframe which is automatically generated by HubSpot and pasting it into the above code for the iframe.

The page I am testing this on is linked here: https://www.silverbug.it/cyber-risk-calculator

 

When you go to the page, the iframe will work perfectly once the UUID is replaced with that in the popup chatbot.

Is there a way I can get it to either work without a UUID, in the iframe url or by pulling in the correct UUID?


1 Akzeptierte Lösung
tjoyce
Lösung
Trendsetter/-in | Elite Partner
Trendsetter/-in | Elite Partner

Chatflow embedded through iframe

lösung

You can run this js @SAncliff - 

let resolved = 0;
window.addEventListener('message', event => {
   let d = (typeof event.data === typeof "") ? JSON.parse(event.data) : event.data;
   if(d.type === 'request-widget' && void 0 !== d.uuid && !resolved) {
       resolved = 1;
       $('#hs_cos_wrapper_widget_1627561115672 iframe').attr('src', $('#hubspot-messages-iframe-container iframe').attr('src'));
   }
});

 

Of course, I hard coded your module id into that script so it would be better to add a class to your target iframe and use that instead, but just dropping this code into the header of your site should work for now.

Lösung in ursprünglichem Beitrag anzeigen

4 Antworten
tjoyce
Lösung
Trendsetter/-in | Elite Partner
Trendsetter/-in | Elite Partner

Chatflow embedded through iframe

lösung

You can run this js @SAncliff - 

let resolved = 0;
window.addEventListener('message', event => {
   let d = (typeof event.data === typeof "") ? JSON.parse(event.data) : event.data;
   if(d.type === 'request-widget' && void 0 !== d.uuid && !resolved) {
       resolved = 1;
       $('#hs_cos_wrapper_widget_1627561115672 iframe').attr('src', $('#hubspot-messages-iframe-container iframe').attr('src'));
   }
});

 

Of course, I hard coded your module id into that script so it would be better to add a class to your target iframe and use that instead, but just dropping this code into the header of your site should work for now.

SAncliff
Teilnehmer/-in | Diamond Partner
Teilnehmer/-in | Diamond Partner

Chatflow embedded through iframe

lösung

That's fantastic. You're a hero!

dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

Chatflow embedded through iframe

lösung

@tjoyce any ideas here? 

@SAncliff , what  is the reason for doing this?

SAncliff
Teilnehmer/-in | Diamond Partner
Teilnehmer/-in | Diamond Partner

Chatflow embedded through iframe

lösung

Mostly as a UX feature. We are looking to embed it in a similar way as HubSpot's own support bot.