In this guide, you will learn how to use variables and logic in UI Builder to define “office hours” and “out-of-office hours”.

These can be used in subsequent logic in your conversational AI application to drive specific business rules such as performing validation checks against a staff roster, checking availability, etc.

Adaptive Expressions

The table below contains all adaptive expressions that will be used in this guide. A description and example are also included:

Expression Description Example Output
float Return the floating point representation of the specified string. float('10.333') 10.333
dayOfWeek Return the day of the week for a given timestamp. dayOfWeek('2023-01-31T13:27:36Z') 2
utcNow Return the current timestamp in an optional locale format as a string. utcNow() 2023-01-31T20:15:00.000Z
formatDateTime Return a timestamp in an optional locale format. formatDateTime('01/31/2023 12:00:00', 'yyyy-MM-ddTHH:mm') 2023-01-31T12:00
convertFromUTC Convert a timestamp in an optional locale format from Universal Time Coordinated (UTC). convertFromUTC('2018-02-02T02:00:00.000Z', 'Pacific Standard Time, 'MM-DD-YY') 02-01-18
dayOfYear Return the day of the year from a timestamp. dayOfYear('2018-03-15T13:27:36Z') 74
or Logical OR operation. Returns true if at least one expression is true, or returns false if all are false. or(true, false) true
contains Check whether a collection has a specific item. Return true
if the item is found, or return false
if not found. This function is case-sensitive. contains('hello world', 'world') world

Learn more about adaptive expressions here.

Key Variables

Implementing logic to initialise office hours and holiday days at a high level involves creating and setting 4 main values. These are stored in dialog scope level variables and are:

turn.CurrentLocalTime

Convert the current time into your desired local time zone:

=string(convertFromUTC(utcNow(), 'Pacific Standard Time', 'yyyy-MM-ddTHH:mm:ss.fffZ'))

dialog.DayOfWeek

The current day of the week: