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 dynamically populate values, such as a 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 behave or collect information by declaring them as Inputs. The inputs are predefined for each function, and you can also use placeholders for each of these functions.


For example, you can ask your customer their name, and while saving it, you can use a function to ensure that it is in the title case. Listed below are the explanations for the functions offered by the bot builder. You can use the corresponding function in your dialog to dynamically populate values in your bot.


Note: While adding functions, you may notice that some of the inputs are marked with an asterisk(*). Any Arguments marked with an asterisk are mandatory.


Function name and description
What inputs do you provide?
Examples
Split
Split a text string at the specified separator and returns the value based on the specified index.
Input text:

The text that needs to be split

Separator:
The character at which you need the text to be split

Index:
The position of the text that needs to be returned. The index position of the string before the separator is zero, and the index position of the string after the separator is one.
Input text:
freshbots-support@freshworks.com

Separator:
@

Index:
0
Output:
freshbots-support
Convert to title case
Convert the formatting of a text string so that it is stored in the title case where the first letter of each word is capitalized.
Input text:
The text that needs to be converted to the title case

Input text:
artificial intelligence

Output:
Artificial Intelligence

Get days between
Returns the count of the number of days between two specified dates (inclusive of the end date)
Start date:
The date from when the counting should start (not included)

End date:

The date till when the counting should continue (included in the count)

Format:

The format in which you are specifying the dates
Start date:
01-01-21

End date:

01-01-22

Format:

dd-MM-yy

Output:
365

Add minutes to date
Adds the specified number of minutes to the specified date
Input date:
The date to which the minutes need to be added

Minutes:

The number of minutes that need to be added to the input date

Format:

The format in which you are specifying the date and time

Input date:
01-01-21 00:15:00

Minutes:

51

Format:

dd-MM-yy HH:mm:ss

Output:

01-01-21 01:07:00
Add hours to date
Adds the specified number of minutes to the specified date
Input date:
The date to which the hours need to be added

Hours:
The number of hours that need to be added to the input date

Format:
The format in which you are specifying the date and time
Input date:
01-01-21 07:04:00 AM

Hours:
12

Format:
dd-MM-yy hh:mm:ss a

Output:
01-01-21 19:04:00
Add days to date
Adds the specified number of days to the specified date

Input date:
The date to which the days need to be added

Days:
The number of days that need to be added to the input date

Format:
The format in which you are specifying the date

Input date:
01-01-21

Days:
12

Format:
dd-MM-yy

Output:
13-01-21

Add days to date with timezone
Adds the specified number of days to the specified date that is denoted along with the timezone

Input date:
The date to which the days need to be added

Days:
The number of days that need to be added to the input date

Format:
The format in which you are specifying the date

Timezone:
The timezone that needs to be denoted along with the date
Input date:
01-01-2021 04:15:00 AM IST

Days:
7

Format:
dd-MM-yyyy hh:mm:ss a z

Timezone:
IST

Output:
08-01-2021 04:15:00 AM IST
Add working days to date with timezone
Adds the specified number of working days to the specified date that is denoted along with the timezone

Please note that, as of today, this function will only account for five working days per week — and will not take into account other holidays or weekday schedules.
Input date:
The date to which the working days need to be added

Working days:
The number of working days that need to be added to the input date

Format:
The format in which you are specifying the date

Timezone:
The timezone that needs to be denoted along with the date

Input date:
01-01-2021 04:15:00 AM IST

Days:
7

Format:
dd-MM-yyyy hh:mm:ss a z

Timezone:
IST

Output:
12-01-2021 04:15:00 AM IST

Add working days to date
Adds the specified number of working days to the specified date.

Please note that, as of today, this function will only account for five working days per week — and will not take into account other holidays or weekday schedules.

Input date:
The date to which the working days need to be added

Working days:
The number of working days that need to be added to the input date

Format:
The format in which you are specifying the date
Input date:
2021-31-01

Days:
7

Format:
yyyy-dd-MM

Output:

2021-09-02
Format date:
Changes the format of the date present, to a different, specified format
Input date:
The date whose format needs to be changed

Format:
The existing format of the specified date

Format:
The format to which the date needs to be updated
Input date:
2021-31-01

Format:
yyyy-dd-MM

Format:
dd-MM-yyyy

Output:
31-01-2021
Extract from list elements:
Split each element in a specified list based on the specified delimiter and returns one value for each element, based on the index value specified

Input list:
The list of elements from which a value needs to be extracted for each list element

Delimiter:

The character or sequence present in each list element. The function will split each list element at this character.

Index:

The position of the text that needs to be returned. The index position of the string before the delimiter is zero, and the index position of the string after the delimiter is one.
Input list:
Room#101, Room#102, Room#103, Room#104

Delimiter:

#

Index:

1

Output:
[101, 102, 103, 104]
Append content:
It takes the specified appended content and appends it to the specified main content 
Main content:
The content to which the text needs to be appended

Appended content:
The content which needs to get appended
Main content:
Hello

Appended content:
 World

Output:
Hello World
Split into list:
Splits the specified string into a list based on the specified delimiter
Main content:
The content that needs to be split into a list.

Delimiter:
The character/string that needs to be used to split the main content into a list.
Main content:
Option 1 and Option 2 and Option 3 and Option 4

Delimiter:
and

Output:

[Option 1, Option 2, Option 3, Option 4]

Extract from list:
Fetches any element from a list based on the specified position (index) of the element
Input list:
The list of elements from which the element needs to be extracted

Index:
The position of the text that needs to be returned. The index value starts from zero for the first element.
Main content:
Option 1, Option 2, Option 3, Option 4

Index:
2

Output:
Option 3
Count working days:
Counts the number of working days between the two specified days.

Please note that, as of today, this function will only account for five working days per week — and will not take into account other holidays or weekday schedules.
Date 1:
The date from when the counting should start

Date 2:

The date till when the counting should continue (included in the count)

Format:

The format in which you are specifying the dates
Date 1:
24-12-2021

Date 2:

06-01-2021

Format:

dd-MM-yyyy

Output:
11
Add integers
Adds any two specified integers
Input integer 1:
The first integer to which the second integer needs to get added.

Input integer 2:
The second integer which will get added to the first integer.
Input integer 1:
123

Input integer 2:
4

Output:

127
Get length
Returns the length of the specified string
Entity:
The string whose length is required
Entity:
Artificial intelligence

Output:
23
Get current date:
Returns the current date in the specified format
Format:
Specify the format in which you need the current date
Format:
dd-MMM-yyyy hh:mm:ss a z

Output:

12-Feb-2021 02:11:23 PM UTC

Compare dates:
The function will compare the primary date with the secondary date and then returns:

1, if the primary date is greater than the secondary date.

0, if both dates are the same

-1, if the primary date is lesser than the secondary date 
Date 1:
The primary date

Date 2:

The secondary date

Format:

The format in which the dates have been entered
Date 1:
11-02-2021

Date 2:

03-02-2021

Format:
dd-MM-yyyy

Output:
1
Compute:
The function calculates the value of the specified expression, and returns the output with up to two decimal points
Input expression:
The expression that needs to be computed
Input expression:
8/(2*4) + 8/2)*4

Output:
17.00

  

 

Note: We have only used a few formats in our examples. You can make use of any of the standardized date and time formats.

All the input fields can take inputs from existing placeholders, such as dialogs, APIs, and parameters. Similarly, you can use the output from any function as a placeholder elsewhere.


Please write to freshbots-support@freshworks.com if you have any more questions; we’ll be happy to help you.