Last updated: 23 June 2021 

Data comes in all shapes and sizes.

Whether it is a date from an external software sent as DDMMYYYY or a token hidden away behind a query string, when you need to access these data points, you need them in the right format.

Formatters allow you to do just that.

Everywhere you can use variables, you have a choice to use formatters to transform a value hidden inside a variable from one format to another.

Below, we dive into each formatter and illustrate them with use cases.

Date formatter

The date formatter allows you to convert any supported date-time format into a format of your choice.

What is the use case?

Imagine you are creating a chatbot capable of booking meetings using our date picker. Our date picker uses the following date format: dd-mm-yyyy.

This is all well and good. But, if you need to send this date to an external software (a CRM, for example), they might require a yyyy-mm-dd date format.

This is where the date formatter comes in.

As you enter your variable inside the integration, use the formatter to convert the original format (dd-mm-yyyy) into the new one.

The date formatter supports the following date-time parameter strings:

String

Description

Example

Days

d

Day of the month with leading zeros

01 to 31

D

Three letter name of the day.

Mon, WedSun

j

Day of the month without leading zeros.

1 to 31

l (lowercase 'L')

Complete name of the day.

Sunday through Saturday

N

Numeric representation of the day of the week, starting at 1 for Monday.

1 for Monday, 3 for Wednesday, etc.

S

English ordinal suffix for the day of the month, two characters.

stndrd or th. Use in combination with j.

w

Numeric representation of the day of the week, starting a 0 for Sunday.

0 (for Sunday) through 6 (for Saturday)

z

The day of the year (starting from 0).

0 through 365

Week

W

Number of the week in the year (weeks starting on Monday).

Example: 42 for the 42nd week in the year.

Month

F

Complete name of the month.

January through December

m

Numeric representation of a month, two characters.

01 through 12

M

Three letter shortcut for the month of the year.

Jan through Dec

n

Numeric representation of a month, without leading zeros.

1 through 12

t

Number of days in the given month.

28 through 31

Year

L

Boolean showing whether it is a leap year.

1 if it is a leap year, 0 otherwise.

o

Week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.

Examples: 1999 or 2003

Y

Numeric representation of a year, four digits.

Examples: 1999 or 2003

y

A two digit representation of a year.

Examples: 99 or 03

Time

a

Lowercase am or pm.

am or pm

A

Uppercase AM or PM.

AM or PM

B

Swatch Internet time

000 through 999

g

12-hour format of an hour without leading zeros.

1 through 12

G

24-hour format of an hour without leading zeros.

0 through 23

h

12-hour format of an hour with leading zeros.

01 through 12

H

24-hour format of an hour with leading zeros.

00 through 23

i

Minutes with leading zeros.

00 to 59

s

Seconds with leading zeros.

00 through 59

u

Microseconds.

Example: 654321

v

Milliseconds.

Example: 654

Timezone

e

Timezone name or identifier.

Examples: UTCGMTAtlantic/Azores

I (capital i)

Boolean showing whether or not the date is in daylight saving time.

1 if Daylight Saving Time, 0 otherwise.

O

Difference to Greenwich time (GMT) without colon between hours and minutes.

Example: +0200

P

Difference to Greenwich time (GMT) with colon between hours and minutes.

Example: +02:00

p

The same as P, but returns Z instead of +00:00

Example: +02:00

T

Timezone abbreviation.

Examples: ESTMDT ...

Z

Timezone offset in seconds.

-43200 through 50400

Full Date/Time

c

ISO 8601 date

2004-02-12T15:19:21+00:00

r

Date formatted using RFC 2822.

Example: Thu, 21 Dec 2000 16:01:07 +0200

U

Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Extract value formatter

The extract value formatter allows you to extract a value appended to a postback.

What is the use case?

Imagine your business sells five different services, such as gardening services, cleaning services, and so on. You are creating a chatbot that would allow users to book your services. This chatbot contains:

  • Five FAQs, one for each service.

  • One conversation, to capture the user’s personal details.

To go from an FAQ to the conversation, you cleverly use an action message and a postback such as enquire_services. While this works perfectly, it would be quite cool to slightly modify the copy of the very first message inside the enquiry conversation to reflect which service the user was asking about originally.

With the value extract formatter, this is now possible.

Simple append the postback on each FAQ with from(cleaning services).

Then, inside your conversation’s first message, attach a variable {{message extract=from}} to resurface the value inside from().

Extract value with regex formatter

The extract value with regex formatter works like the extract value formatter, except it will grab the first item that matches the inputted regex.

URL parameters

The URL parameters formatter allows to extract a value behind the parameter of a URL.

What is the use case?

Imagine your chatbot lives on a page of your website. To get to that page, users need to log into your web portal. Once logged in, they are redirected to a page where they can interact with your chatbot. This page URL has the following format:

https://my-website.com/welcome?token=lwpl2aow12019kda

What you would really like to do is verify that every single user talking to your chatbot is actually logged in. The URL parameter formatter allows you to do that by extracting the value behind token=. Once extracted, this token can be used in an integration to verify the user is, indeed, logged in.

Convert variable type formatter

The convert variable type formatter allows you to convert data format into another.

What is the use case?

Imagine you are setting up an integration. This integration allows you to capture data inside your chatbot and send it to an external software.

Alas, the data captured inside your platform adheres to a number format and the external software only accepts JSON format. Here comes the convert variable type formatter!

Use this formatter to change number, float, or JSON formats for another.