# Opening live chat via javascript

**URL:** <https://community.hubspot.com/t/opening-live-chat-via-javascript/12523>\
**Category:** APIs & Integrations\
**Created:** [December 22, 2018, 11:26pm UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523 "2018-12-22T23:26:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriscardone](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chriscardone/32/30982_2.png) [@chriscardone](https://community.hubspot.com/u/chriscardone)\
**Post date:** [December 22, 2018, 11:26pm UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523/1 "2018-12-22T23:26:26Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [December 27, 2018, 3:03pm UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523/2 "2018-12-27T15:03:41Z")

</div>

Hi, [@Chris\_Cardone](https://community.hubspot.com/u/chris_cardone).

Your request seems similar to [this topic](https://integrate.hubspot.com/t/autostart-hubspot-bot/13635). 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](https://knowledge.hubspot.com/articles/kcs_article/conversations/how-to-use-conversations#automatically-open).

This feature was implemented due to feedback on [this HubSpot Community request](https://community.hubspot.com/t5/HubSpot-Ideas/Possibility-to-open-the-chat-window-by-using-custom-button-js/idi-p/175889). The thread includes some helpful code examples from other developers.

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [May 3, 2019, 2:45pm UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523/3 "2019-05-03T14:45:12Z")

</div>

You could also do -

`hubspot.messages.EXPERIMENTAL_API.requestWidgetOpen()`

---

[tim@belch.io](mailto:tim@belch.io)

---

<div class="post-metadata">

**Author:** ![cbarley](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cbarley/32/82559_2.png) [@cbarley](https://community.hubspot.com/u/cbarley)\
**Post date:** [May 5, 2019, 11:38pm UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523/4 "2019-05-05T23:38:20Z")

</div>

hi @chriscardone and @tjoyce , we also just released a [Conversations Live Chat Widget API](https://developers.hubspot.com/docs/methods/conversations_api/hubspot-conversations-javascript-api), where you can use this [this function](https://developers.hubspot.com/docs/methods/conversations_api/widget_open) to open the widget:

`window.HubSpotConversations.widget.open(); `

---

<div class="post-metadata">

**Author:** ![rampatra](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rampatra/32/53869_2.png) [@rampatra](https://community.hubspot.com/u/rampatra)\
**Post date:** [April 23, 2020, 7:47pm UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523/5 "2020-04-23T19:47:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![peacepostman](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/peacepostman/32/62359_2.png) [@peacepostman](https://community.hubspot.com/u/peacepostman)\
**Post date:** [May 13, 2019, 10:22am UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523/6 "2019-05-13T10:22:45Z")

</div>

Hello,

We succeed using this javascript call:

```auto
// Open chat
HubSpotConversations.widget.open()

// Close chat
HubSpotConversations.widget.close()

```

Best regards,

---

<div class="post-metadata">

**Author:** ![hakancanada](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hakancanada/32/62922_2.png) [@hakancanada](https://community.hubspot.com/u/hakancanada)\
**Post date:** [February 17, 2023, 7:49pm UTC](https://community.hubspot.com/t/opening-live-chat-via-javascript/12523/7 "2023-02-17T19:49:07Z")

</div>

Hi all,

Is it possible to hide bubble on mobile and only allow users to open with link clicking?
