Tips, Tricks & Best Practices

FMola
Participant

Launching chat from a link

SOLVE

hubspot chat error.png
Hi, I'm getting this error by using

onclick="window.hubspot.messages.EXPERIMENTAL_API.requestWidgetOpen();

 

0 Upvotes
1 Accepted solution
MatthewShepherd
Solution
Key Advisor

Launching chat from a link

SOLVE

Hi @FMola 

I believe the EXPERIMENTAL_API is deprecated so you can just use window.HubSpotConversations.widget.open() in your onclick instead. Here's an example:

 

<a href="#" id="click-to-chat__cta--text" class="cta cta--blue" style="margin-top: 20px;" onclick="window.HubSpotConversations.widget.open();">Chat with Sales</a>

 

 

and here are a few other threads that discuss this and other approaches:

https://community.hubspot.com/t5/Tickets-Conversations/Click-to-launch-chat/m-p/406564

https://community.hubspot.com/t5/Tickets-Conversations/Click-to-launch-chat/m-p/405402 

I hope that helps!

 

Matthew Shepherd

Freelance HubSpot Consultant
CRM Consultant | SEO Specialist

Did my post help answer your query?Help the community by marking it as a solution.

View solution in original post

4 Replies 4
kvlschaefer
Community Manager
Community Manager

Launching chat from a link

SOLVE

Hi @FMola,

 

Welcome to the Community!

It would be great if you can share which troubleshooting steps you have taken so far so the Community has more information to work with. 

 

Thank you,

Kristen


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes
FMola
Participant

Launching chat from a link

SOLVE

Thanks for the prompt response kvonloesecke,
The code below worked for me, 

document.getElementById("hschat1").innerHTML = '<a href="#" onclick="window.history.pushState; window.HubSpotConversations.clear({resetWidget:true});">Open Chat</a>'

But it's changing the element text, is there any possibility to trigger it without changing the inner html element? It's actually on WordPress. I can assign an id or class to the button & use onclick event to do the job.

0 Upvotes
MatthewShepherd
Solution
Key Advisor

Launching chat from a link

SOLVE

Hi @FMola 

I believe the EXPERIMENTAL_API is deprecated so you can just use window.HubSpotConversations.widget.open() in your onclick instead. Here's an example:

 

<a href="#" id="click-to-chat__cta--text" class="cta cta--blue" style="margin-top: 20px;" onclick="window.HubSpotConversations.widget.open();">Chat with Sales</a>

 

 

and here are a few other threads that discuss this and other approaches:

https://community.hubspot.com/t5/Tickets-Conversations/Click-to-launch-chat/m-p/406564

https://community.hubspot.com/t5/Tickets-Conversations/Click-to-launch-chat/m-p/405402 

I hope that helps!

 

Matthew Shepherd

Freelance HubSpot Consultant
CRM Consultant | SEO Specialist

Did my post help answer your query?Help the community by marking it as a solution.
FMola
Participant

Launching chat from a link

SOLVE

Hello MatthewShepherd,
This worked for me 
window.HubSpotConversations.widget.open()
Exactly what I was looking for,
Thank you so much!

0 Upvotes