Using time in your chatbot

With Chatlayer, you can use the time variable to guide your flow based on the current moment in time.

A Chatlayer customer, for example, uses this to determine if it's winter or summer, and will recommend tires based on the current season.

To implement this, first create an Action bot dialog that contains an API plugin with a GET request.

In the URL field enter functions/time/getTime . You don't have to add any headers or query parameters.

This action saves the time variable to the session of the user. You can use it in your Go To's and Bot Messages with the following variables:

  • time.year

  • time.month

  • time.days

  • time.hours

  • time.minutes

  • time.seconds

All variables will return a number. You can use them in your flow like this: