Enforcing offline hours
However, there may be cases where you want to force Olark to display as unavailable even when you have available agents - for example, if you want to enforce particular off-hours in the evening.
Steps using our JavaScript API
You'll want to get the get the current time. The quickest way to do this is to get the visitor's browser time:
Olark will automatically detect when you have agents available to chat.Be aware, however, that a visitor's browser time may not be accurate. For a more robust solution, you may wish to use your server time or find an alternative method.
In our case, we want to calculate the time relative to San Francisco.
Using some JavaScript if statements for our own particular use case, we can finally use the API call that forces the chat box offline in the visitor's browser:
Important Notice: We’ll do our best to help with any questions you have. However, keep in mind that the API is intended to be self-serve for web developers, so we’re not able to write or debug your code. If you’re experiencing issues, please be sure to have your developer, designer or webmaster review code you’ve written.