Setting up dialogs in your bot builder to send out preset responses to customers is pretty straightforward. However, depending on your business, you will want certain portions of your response to populate values dynamically, for example: timestamp (date & time). 


The bot builder provides you with commonly used functions for your daily operations, such as fetching current date, separating strings by a delimiter, manipulating date and time, etc. These Functions act as placeholders and take care of populating values for these fields dynamically. What’s more, you can also define how you want each function to act or collect information by declaring them as 'Inputs'. 


For example:

Split function:

This function splits the given text based on the delimiter/separator and returns the value based on the index specified.

Syntax: $fn{{#split)}}

Usage: $fn{{#split('chat&bots','&','1')}} 

The ‘&’ here is the separator which will split the text, 1 is the index indicating the position of which value should be returned (0 being the position of the first value).

Output: bots


Listed below is the explanation for the most common functions the bot builder offers. You can use the corresponding function in your dialog to dynamically populate values in your bot.


Note: Arguments marked with an asterisk (*) are mandatory.


Function Name & Description

Inputs

Preview

Add hours to date

Gives the date after adding time interval - in hours, to the input date

Input Date* - Date to be modified

(eg: 2019-08-24 00:15:00)

Hours* - Time interval to be added to input date- (eg: 12)

Format* - Format of Input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

$fn{{#addHoursToDate)}}


Example: 

$fn{{#addHoursToDate('2019-08-24 00:15:00',12,'yyyy-MM-dd hh:mm:ss')}}


Output: 2019-08-24 12:15:00

Add minutes to date

Gives the date after adding time interval - in minutes, to the input date

Input Date*- Date to be modified 

(eg: 2019-08-24 00:15:00)

Minutes* - Time interval to be added to input date (eg: 51)

Format*- Format of Input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

$fn{{#addMinutesToDate)}}


Example: 

$fn{{#addHoursToDate('2019-08-24 00:15:00',51,'yyyy-MM-dd hh:mm:ss')}}


Output: 2019-08-24 01:06:00

Split

Splits the given text based on the separator and returns the value based on the index specified

Input Text*- Text that needs to be split (eg: fresh&bots)

Separator*- Character used to split the input text (eg: &)

Index*- Position of sub-text that needs to be retrieved (0 being the position of the first sub-text) (eg: 1)

$fn{{#split)}}


Example: 

$fn{{#split('fresh&bots','&','1')}}


Output: bots

Get days between

Gives the count of days between two dates (inclusive of end date)


Start Date*- Start date 

(eg: 2019-08-22 00:00:00)

End Date*- End date 

(eg: 2019-08-28 00:00:00)

Format*- Format of Input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

$fn{{#getDaysBetween)}}


Example: 

$fn{{#getDaysBetween('2019-08-22 00:00:00','2019-08-24 00:00:00','yyyy-MM-dd hh:mm:ss')}}


Output: 2

Convert to title case

Converts the formatting of the text to title case

Input Text* - Text that needs to be formatted to title case (eg: artificial intelligence)

$fn{{#toTitleCase)}


Example: 

$fn{{#toTitleCase('artificial intelligence')}}


Output: Artificial Intelligence

Format Date

Changes the format of the date to the required, mentioned format

Input Date*- Date to be modified 

(eg: 2019-09-12 12:59:59)

Input Format*- Current format of Input Date-Time 

(eg: yyyy-MM-dd hh:mm:ss)

Output Format*- Required Date-Time format of result (eg: dd-MM-yyyy hh:mm:ss)

$fn{{#formatDate)}}


Example: 

$fn{{#formatDate('2019-09-12 12:59:59','yyyy-MM-dd hh:mm:ss','dd-MM-yyyy hh:mm:ss')}}


Output: 12-09-2019 12:59:59

Append content

Appends content to another content

Main Content*- Content to which text needs to be appended (eg: fresh)

Appended Content*- Content to be appended (eg: bots)

$fn{{#appendInNotEmpty)}}


Example: 

$fn{{#appendInNotEmpty(‘fresh’,‘bots’)}}


Output: freshbots

Split into List

Splits the text content into list

Main Content*- Content to be split (eg: artificial intelligence/machine learning)

Delimiter - Character used splits the content. By default, comma (,) will be used. (eg: /)


$fn{{#stringAsList('true')}}


Example: 

$fn{{#stringAsList('artificial intelligence/machine learning','/','true')}} 


Output: [artificial intelligence, machine learning]

Get length

Gives the length of the entity

Entity* - Entity whose length is to be found out (eg: machine learning)

$fn{{#getLength)}} 


Example: 

$fn{{#getLength('machine learning’)}} 


Output: 16

Add days to date

Gives the date after adding the specified time interval to the input date

Input Date*- Date to be modified 

(eg: 2019-08-24 00:00:00)

Days*- Time interval to be added to input date in days (eg: 15)

Format*- Format of input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

$fn{{#addDates)}}


Example: 

$fn{{#addDates('2019-08-24 00:00:00',15,'yyyy-MM-dd hh:mm:ss')}} 


Output: 2019-09-08 00:00:00

Add days to date with timezone

Gives the date with corresponding timezone after adding the specified time interval to the input date

Input Date*- Date to be modified 

(eg:  2019-08-24 00:00:00)

Days*- Time interval to be added to input date in days (eg: 15)

Format*- Format of Input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

Timezone*- Format of input timezone (eg: Europe/Copenhagen)

$fn{{#addDatesWithTimeZone)}}


Example: 

$fn{{#addDatesWithTimeZone('2019-08-24 00:00:00',15,'yyyy-MM-dd hh:mm:ss','Copenhagen')}}


Output: 2019-09-08 00:00:00

Add working days to date with timezone 

Gives the date upon adding the number of working days to the input date

Input Date*-  Date to be modified (eg: 2019-08-24 00:00:00)

Working Days*- No. of working days to be added to input date (eg: 10)

Format*- Format of input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

Timezone*- Format of input Timezone (eg: Europe/Copenhagen)


$fn{{#addWorkingDatesWithTimeZone)}}


Example: 

$fn{{#addWorkingDatesWithTimeZone('2019-08-24 00:00:00',15,'yyyy-MM-dd hh:mm:ss','“Europe/Copenhagen”')}}


Output: 2019-09-08 00:00:00

Add working days to date 

Gives the date after adding number of working days to the input date

Input Date*- Date to be modified 

(eg: 2019-08-24 00:00:00)

Working Days*- No. of working days to be added to input date (eg: 10)

Format*- Format of Input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

$fn{{#addWorkingDates)}}


Example: 

$fn{{#addWorkingDates('2019-08-24 00:00:00',10,'yyyy-MM-dd hh:mm:ss')}}


Output: 2019-09-11 00:00:00

Extract from list elements

Splits and extracts a portion of every element from a list based on the position of the delimiter

Input List*-  List the elements that need to be split and extracted from (eg: a1#b1,a2#b2)

Delimiter*- Character/sequence that splits each list element (eg: #)

Index* - Index of the element to be split (0 being the first element) (eg: 0)

$fn{{#splitAll)}}


Example: 

$fn{{#splitAll('a1#b1,a2#b2','#','0')}} 


Output: a1,a2

Extract from List

Fetches any element from a list

Input List* - List from which element needs to be extracted (eg: agents, groups, roles)

Index*- Index of element to be fetched (0 being first element) (eg: 0)

$fn{{#getElement)}}


Example: 

$fn{{#getElement('agents,groups,roles','0')}} 


Output: agents

Count working days

Counts the number of working days between two dates

Date 1*- First date to be checked (eg: 2019-09-02 00:00:00)

Date 2*- Second date to be checked (eg: 2019-09-09 00:00:00)

Format*- Format of input Date-Time (eg: yyyy-MM-dd hh:mm:ss)

$fn{{#getWorkingDaysBetween)}}


Example: 

$fn{{#getWorkingDaysBetween('2019-09-02 00:00:00','2019-09-09 00:00:00','yyyy-MM-dd hh:mm:ss')}} 


Output: 5

Add integers

Adds any two integers

Input Integer 1*- First integer to be added (eg: 2)

Input Integer 2*- Second integer to be added (eg: 2)

$fn{{#addInt)}}


Example: 

$fn{{#addInt(2,2)}}


Output: 4

Fetch text form HTML

Fetches text content from HTML input

HTML Input*- HTML code from which content needs to be fetched (eg: <p>Hello  <b>world</b></p>)

$fn{{#stripHtml)}} 


Example: 

$fn{{#stripHtml('<p>Hello <b> world </b> </p>')}}


Output: Hello world

Decode Base64 to Text

Decode and convert base64 into text format

Input Text* - Base64 encoded string to be converted (decoded) to Text format 

(eg: Y29udGVtcGxhdGluZw==)

$fn{{#base64Decode)}}


Example: 

$fn{{#base64Decode('Y29udGVtcGxhdGluZw==')}} 


Output: contemplating

Get Current Date

Gives the current date in the provided format for the UTC timezone

Format*- Format of input Date-Time (eg: dd-MM-yyyy hh:mm:ss)

$fn{{#getCurrentDate)}}


Example:

$fn{{#getCurrentDate('yyyy-MM-dd hh:mm:ss')}}


Output: 13-09-2019 06:32:29

Compare Date

Compares dates and returns:

  • 1 if primary date string > secondary date string

  • 0 if both the date strings are equal

  • -1 if primary date string < secondary date string

Date 1*- Primary date string to be compared 

(eg: 2019-09-11 06:30:30)


Date 2*- Secondary date string to be compared 

(eg: 2019-09-14 06:30:30)


Format*- Format of input Date-Time (eg: yyyy-MM-dd hh:mm:ss)


$fn{{#compareDate('','','')}}


Example:

$fn{{#compareDate('2019-09-11 06:30:30','2019-09-14 06:30:30','yyyy-MM-dd hh:mm:ss')}}


Output: -1

Contains Any

Takes two inputs - a string and a list.


Return True if the list contains the string and False if it does not. 

It is case sensitive.


String*- String to be checked for 

(eg: 'bot')


List*- Strings separated by commas (should not be empty) 

(eg: 'learn','machine','trigger','bot')

$fn{{#containsAny('', '', '')}}


Example:

$fn{{#containsAny(‘bot’, 'learn',’machine’,’trigger’,’bot’)}}


Output:True