Opening live chat via javascript

SOLVE
Highlighted
Regular Contributor

We're trying to make it so a button can open the live chat widget via javascript, how could we do this?

(by live chat, I am referring to the hubspot live chat widget)

Reply
0 Upvotes
2 Accepted solutions

Accepted Solutions
Highlighted
Solution
HubSpot Employee

Hi, @Chris_Cardone.

Your request seems similar to this topic. If you use JavaScript to append #hs-chat-open to the end of the URL, the chat widget will open immediately.

Check out the documentation here .

This feature was implemented due to feedback on this HubSpot Community request . The thread includes some helpful code examples from other developers.

Isaac Takushi

Alumnus, HubSpot Developer Support

View solution in original post

Reply
0 Upvotes
Highlighted
Solution
HubSpot Alumni

hi @chriscardone and @tjoyce , we also just released a Conversations Live Chat Widget API, where you can use this this function to open the widget:

 

window.HubSpotConversations.widget.open();  

 

View solution in original post

5 Replies 5
Highlighted
Solution
HubSpot Employee

Hi, @Chris_Cardone.

Your request seems similar to this topic. If you use JavaScript to append #hs-chat-open to the end of the URL, the chat widget will open immediately.

Check out the documentation here .

This feature was implemented due to feedback on this HubSpot Community request . The thread includes some helpful code examples from other developers.

Isaac Takushi

Alumnus, HubSpot Developer Support

View solution in original post

Reply
0 Upvotes
Top Advisor | Platinum Partner

You could also do -

hubspot.messages.EXPERIMENTAL_API.requestWidgetOpen()

---

tim@belch.io

Reply
0 Upvotes
Highlighted
Solution
HubSpot Alumni

hi @chriscardone and @tjoyce , we also just released a Conversations Live Chat Widget API, where you can use this this function to open the widget:

 

window.HubSpotConversations.widget.open();  

 

View solution in original post

Highlighted
New Contributor

This worked for me. Also, is there a way to also type in a default message automatically from the user side when the window opens?

Reply
0 Upvotes
Highlighted
Visitor

Hello,

 

We succeed using this javascript call:

 

// Open chat
HubSpotConversations.widget.open()

// Close chat
HubSpotConversations.widget.close()

Best regards,

Reply
0 Upvotes