OLD BUILDER - How to change bot depending on business hours (open or closed/weekend)

We know that offer a personalize experience for our visitors is really important, and sometimes you might want to offer a different experience depending if your business is open or close, if you want to make the most of the Human Takeover, or let the user browse and let messages be answered after.

Scenario: You want to display a different bot if the business is open or closed.

With this in mind we can build 2 bots:

  • A bot focused on attending customers in real time with the option to jump into the conversation with a potential client, or attending requests.
  • Other bot focused in offering information, FAQs or capturing leads, that you will answer after.

For that what we are going to do is to use the following code, to embed in our sites, instead of the one given by default by Landbot:

To customize it to our needs, we need to edit the code as follows:

  1. We need to establish our GMT timezone, so that the bot works with your time zone, not the visitor time zone. In this case, for example if we are in Barcelona is GMT -1:00, therefore our const gmt has to be ["-",1,0]
const gmt = ["-", 1, 00]; //Examples: GMT-6:00 => ["-", 6, 0], GMT+1:00 => ["+", 1, 0], GMT-3:30 => ["-",3,30]
  1. Here we will write the time when the business is open, in this case will be local time, you don't need to change it for the time zone
const localOpenTimeWrkDays = [9,0]; //Examples: 09:00am => [9,0], 10:30am => [19, 30]
  1. As above, but this time for the closing time. If you close at 07:15 pm, will be [19,15]
const localClosingTimeWrkDays = [18,0]; //Examples: 06:00pm => [18,00], 19:30 => [19,30]
  1. In this line we will change the url between the " " , for he bot we want to be displayed during business hours
const landbotUrlBusinessOpen = "https://landbot.io/u/H-116518-LRMRPCEOUENE0LGK/index.html";
  1. As above we will change the url, but for the hours the business is closed
const landbotUrlBusinessClosed = "https://landbot.io/u/H-116690-O0PCPQYT66ACULA4/index.html";

The code is created for businesses that are open from Monday to Friday, weekends are considered by default as closed

These scripts and how to's are not native functionalities. Landbot won't be able to support, help or guarantee these scripts and how to's. These Workarounds and How to's are for developers, as a learning and example material on how to extend or modify some of the platform limitations.  Due to platform updates, some scripts might stop working in the future.Please, note that in case of Scripts and Workaround the Custom Success Team can deliver limited support.

How did we do?