APIs & Integrations

jpfaller
Member

How to check if chat widget is available (timeframe set)?

Hello everyone!


We have a chat widget on our website which works totally fine. In the HubSpot settings, we've set a specific timeframe in which this widget is visible on our website (09:00 - 17:00). Outside of this timeframe, the widget is hidden.
Now, we've built custom buttons we're using on our website that opens the chat on button press, via the open()-function. But if a visitor visits our website in the evening, for example at 19:00, the chat is not available and so a button has no functionality.
Unfortunately, I can't find any possibility to check the timeframe set in HubSpot with which I could hide the buttons in case the chat widget is hidden (= outside of set time the chat is available).
Is there any way for doing that? Or is there any way I could check if the widget itself is loaded and really visible?

 

Thanks in advance!

0 Upvotes
5 Replies 5
miljkovicmisa
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

How to check if chat widget is available (timeframe set)?

Hi @jpfaller , you could use the javascript variable that is available like this:

 

console.log(hubspot_live_messages_running);

 

 This returns the value true of false depending on if the chat is currently running.

Other options include the javascript available object HubSpotConversations which you can console log to see available functions.

If you need any further help don't hesitate to write here.

If my answer was helpful please mark it as a solution.

jpfaller
Member

How to check if chat widget is available (timeframe set)?

Thanks for your reply, @miljkovicmisa!

Unfortunately, it's not solving my issue. The var `hubspot_live_messages_running` also returns `true` if the chat is hidden (= off hours as defined in HubSpot).

 

In the object `HubSpotConversations`, I can't see anything that really helps me since the chat-widget itself is loaded in the background but not shown since it's off-hours.

0 Upvotes
CMcKay
Top Contributor

How to check if chat widget is available (timeframe set)?

So you also don't want to show the Button in the off hours? Or you want to show the button in the off hours and popup the chat? 

0 Upvotes
jpfaller
Member

How to check if chat widget is available (timeframe set)?

I would like to not show the button during the off hours.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

How to check if chat widget is available (timeframe set)?

Hi, @jpfaller 👋 Thanks for reaching out. Hey @CMcKay  @albertsg @miljkovicmisa, do you have any thoughts here? 

 

Additionally, thank you for taking time to lay out what you've tried and the roadblocks and limitations you are facing. It helps the community so much when trying to offer suggestions.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes