Opening live chat via javascript

resolver
Highlighted
Colaborador Frequente

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)

Responder
0 Avaliação positiva
2 Solução aceitas

Soluções aceitas
Highlighted
Moderador da HubSpot

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

HubSpot Developer Support
Responder
0 Avaliação positiva
Alunos da HubSpot

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();  

 

5 Respostas 5
Highlighted
Moderador da HubSpot

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

HubSpot Developer Support
Responder
0 Avaliação positiva
Highlighted
Consultor de Alto Nível | Parceiro Platinum

You could also do -

hubspot.messages.EXPERIMENTAL_API.requestWidgetOpen()

---

tim@belch.io

Responder
0 Avaliação positiva
Alunos da HubSpot

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();  

 

Highlighted
Colaborador Iniciante

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?

Responder
0 Avaliação positiva
Highlighted
Visitante

Hello,

 

We succeed using this javascript call:

 

// Open chat
HubSpotConversations.widget.open()

// Close chat
HubSpotConversations.widget.close()

Best regards,

Responder
0 Avaliação positiva