Message Templating
Messaging templating can help you add more context to bot messages and button labels. With help of templating a bot can send messages like:
- Hi <Name> : The user name will be replaced at runtime.
- Hi Sir: Based on gender the bot can determine whether to use Sir or Mam.
Syntax
We use Handlebars as tempalting language. We support everything that can be done with handlerbars. The templating will work on following texts:
- Any simple plain text.
- Button labels
- Suggestion/Quick Reply Labels
Variable
Following variables will be available at the runtime to use with message templating:
FNAME
: Represents the first name of the user.LNAME
: Represents the last name of the user.NAME
: Represents the complete name of the user.MALE
: Will be true if the customer is male.FEMALE
: Will be true if the customer is female.EMAIL
: Represents user's email.DATE
: Represents current date in following formatThu, Sep 1, 2017
.TIMESTAMP
: Represents current date in following format03:25 pm Thu, Sep 1, 2017
.
To request any new variable please contact us.
Example
In all the examples the result will be rendered assuming following user:
Name: Abhishek Gupta
Gender: Male
Customer name
Input: Hi {{FNAME}}, how are you?
Output: Hi Abhishek, how are you?
Input: Hi {{LNAME}}, how are you?
Output: Hi Gupta, how are you?
Input: I am booking the tickets under \{{NAME}}.
Output: I am booking the tickets under Abhishek Gupta.
Customer gender
Input: Hi {{#MALE}}Sir{{/MALE}}{{#FEMALE}}Mam{{/FEMALE}},
Output: Hi Sir,
Customer name with default value
Input: Hi {{#NAME}}{{NAME}}{{/NAME}}{{^NAME}}{{#MALE}}Sir{{/MALE}}{{#FEMALE}}Mam{{/FEMALE}}{{/NAME}},
Output: Hi Abhishek,