🕒

Time based chatbots

Created
Feb 17, 2022 2:23 AM
Created by
Jacob Molina
Status
Not started

If you prefer you can pass start and stop time to set a range where the chatbot will work.

Please ensure that your webchat client is on a version that supports this feature. See below...

<script src="<https://widget.botco.ai/prod/202103017/widget.js>" />

// Botco Installation
// Note: this installs the Botco chatbot but does with a time range defined to work
<script>

	const startDateTime = new Date();
	startDateTime.setUTCHours(2, 0, 0);
	const endDateTime= new Date();
  endDateTime.setUTCHours(11, 0, 0);

//The bot will be activated from 10:00pm EST to 7:00am EST
  BotcoWebchat.mount({
    apiKey: 'YOUR_KEY',
		startDateTime,
		endDateTime
  });
</script>

In this example the bot will be visible from the 10:00pm EST of the current day to the 7:00am EST of the next day.

<aside> â›” Note: Times must be in UTC or they will change for each user If you want the times to be related to each user, use setHours instead of setUTCHours

</aside>

The bot will work as normally work during the time range you defined previously, but if you try to open before the time range, the bot will not be visible.

Note: If the chatbot is open and the time comes that it should close, it will NOT remove itself until the current conversation window is closed.

image

Weekends AI Chatbot

if you prefer you can additionally pass and always start and stop time to set a range where the chatbot will work ignoring the normally established hours.

<script src="<https://widget.botco.ai/prod/202103017/widget.js>" />

// Botco Installation
// Note: this installs the Botco chatbot but does with a time range defined to work,
// and a range where will work despine the defined range.
<script>

	const startDateTime = new Date();
	startDateTime.setUTCHours(2, 0, 0);
	const endDateTime= new Date();
  endDateTime.setUTCHours(11, 0, 0);
  const alwaysOnStartTime = { day: "saturday", hour: "04:00" }; // Times in UTC
  const alwaysOnStopTime = { day: "sunday", hour: "03:59" };  // UTC

//The bot will be activated from 10pm EST to 7:00am EST
// and will be always active the from saturday 12:00am EST to sunday 11:59pm EST
  BotcoWebchat.mount({
    apiKey: 'YOUR_KEY',
		startDateTime,
		endDateTime,
    alwaysOnStartTime,
    alwaysOnStopTime
  });
</script>

Multiple Chatbots depending on time

Some customers would like different responses based on the time of day. This can be used to have two completely different chatbots.

<aside> 🤔 Having a time-based go-to card in the app is a requested feature we are considering as well

</aside>

Example

const DAYTIME_BOT_API_KEY = '' // Your daytime chatbot
const NIGHTTIME_BOT_API_KEY = '' // Your nighttime chatbot

const switchToNight = new Date();
const switchToDay = new Date();

switchToDay.setUTCHours(16, 0); // 16:00 UTC is 8am PST
switchToNight.setUTCHours(5, 0); // 5:00 UTC is 9pm PST

BotcoWebchat.mount({
  apiKey: DAYTIME_BOT_API_KEY,
  startDateTime: switchToDay,
  endDateTime: switchToNight,
});

BotcoWebchat.mount({
  apiKey: NIGHTTIME_BOT_API_KEY,
  startDateTime: switchToNight,
  endDateTime: switchToDay,
});