Set Custom Hours for Smith.ai Chat

Does your staff answer website chats live using Intercom, Zendesk Chat, HubSpot, or another tool, but only during normal business hours? You can add Smith.ai Live Chat for coverage on the nights and weekends! All you need is a Live Chat account and a bit of extra code added to your widget.

That way, you get 24/7 live agents answering chats from new leads and existing clients. And you won't need to play catch up and phone tag the next business day when your team is back in the office.

Send this code to your developer and have them customize it for the hours you need, then add it to your Smith.ai chat widget code.

Developer notes:

This code is an example of how to only show the widget to a guest during a schedule defined in your timezone. When the guest visits a page, the code will compare their current time to the time in your timezone and make a decision if the guest is visiting during the 7-day schedule you defined. It will work the same on days when your staff may be gone all day (July 4th, December 25th, etc).

Required libraries:

The JavaScript libraries will add weight to a page, but only for the first visit from a guest.

Sample code:

<html …>
<head>…</head>
<body>


<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.31/moment-timezone-with-data.min.js"></script>


<script type=”text/javascript”>

window.addEventListener('load', function ($ev) {

// 1 - define your timezone
// note: you can find your time zone's name on the map here: https://momentjs.com/timezone/
var timezone = 'America/Los_Angeles'

// 2 - define your 7-day schedule in 24 hour clock
// note: for any days you do not wish to show the at all widget, set start and end to '00:00'
var schedule = {
Monday: {start: '08:00', end: '18:00'},
Tuesday: {start: '08:00', end: '18:00'},
    Wednesday: {start: '08:00', end: '18:00'},
    Thursday:  {start: '08:00', end: '18:00'},
    Friday:    {start: '08:00', end: '18:00'},
    Saturday:  {start: '10:00', end: '14:00'},
Sunday: {start: '00:00', end: '00:00'},
  }

// 3 - get the guest’s current time and day of the week in your timezone
var now = moment().tz(timezone)
var weekDay = now.format('dddd')
var time = now.format('HH:mm')

// 4 - check if the guest's current time is within your schedule
if (time >= schedule[weekDay].start && time <= schedule[weekDay].end) {
  // What you want to happen during the above hours
// e.g. Add Intercom or Zendesk Chat widget install script
} else {
// What you want to happen after the above hours
// e.g. Add Smith.ai widget install script
}
})

</script>
</body>

Questions? Contact us!

If you're already a Smith.ai client and need help, please email us at support@smith.ai or call us at (650) 727-6484 for assistance.

If you're not yet a Smith.ai client, please schedule a free consultation to get started with our live chat or email us at sales@smith.ai. We'll help you select the best plan to match your business’s growth goals and budget.

How did we do?

Require a phone number to initiate Smith.ai chats

Setting Your Notification Preferences for Web Chat

Contact