Working with dates and time in a bot

Get and convert the current time to required format

Get the current date and time with helper:

{{formatDate (now) "DD.MM.YYYY HH:mm" "ru"}}

Set a value to Time variable with Assign a variable component. Since we only want to know when user entered the bot, we need to remove the date from the helper and leave only hours and minutes:

{{formatDate (now) "HH:mm" "ru"}}

Process the time and translate to set screens

Put Fork component to the screen. Set The variable name to Time.

It’s easier to make the regular expression for the first interval — 10 to 19:


Add this regular expression to the Fork value. In Data Type select Regular expression. The default target is 19 to 10 interval.

Format the bot reply screens and we’re done.


To convert the current date, we can use helper:

{{formatDate (now) "DD.MM.YYYY" "en"}}

There is another helper to convert a user-input date:

{{formatDate Date1 "DD.MM.YYYY" "en"}}

Where Date1 is a user-input date value.

The bot can be implemented like this:

Use helper to add one day to the current date:

{{addDate (formatDate now "DD.MM.YYYY h:mm:ss a" "en") 1 "days" "DD.MM.YYYY h:mm:ss a" "en"}}

You can change 1 to the desired number of days that you add:

{{addDate (formatDate now "DD.MM.YYYY h:mm:ss a" "en") 15 "days" "DD.MM.YYYY h:mm:ss a" "en"}}

Change "days" to "months" to add months:

{{addDate (formatDate now "DD.MM.YYYY h:mm:ss a" "en") 1 "months" "DD.MM.YYYY h:mm:ss a" "en"}}

To "weeks" to add weeks:

{{addDate (formatDate now "DD.MM.YYYY h:mm:ss a" "en") 1 "weeks" "DD.MM.YYYY h:mm:ss a" "en"}}

To "years" to add years:

{{addDate (formatDate now "DD.MM.YYYY h:mm:ss a" "en") 1 "years" "DD.MM.YYYY h:mm:ss a" "en"}}

To "quarters" to add quarters:

{{addDate (formatDate now "DD.MM.YYYY h:mm:ss a" "en") 1 "quarters" "DD.MM.YYYY h:mm:ss a" "en"}}

You can test these and other options in the sandbox:

Helper for output month in a form of a word

The month in a date is usually output as a number, but if you need the name of the month, you can use helper:

{formatDate (now) "MMM" "en"}}

How to display the day of the week

The day of the week in the form of an ordinal number can be displayed using the helper:

{{formatDate now "d" "en"}}

In this format, days will be counted from 0 to 6, where 0 is Sunday, 1 is Monday, etc. To display the days of the week in abbreviated form ("Mo"), the helper will help:

{{formatDate now "dd" "en"}}

So you can display the days of the week in full ("Monday", "Tuesday", etc.):

{{formatDate now "dddd" "en"}}

The date will be converted depending on what day of the week the user logged in.

You can find information on other types of date format here