Templates
Create bot conversation flows
Templates are the building blocks of JAWCE. They define the conversation flow which the bot respond to the user.
The 2 folders (templates
& triggers
) contains both conversation flow and another (trigger) file which
looks like it contains info that's not supposed to be there, but no.
Let's look at the contents of these folders in detail
Triggers
Most chatbots have a start word(s) or just a keyword that can trigger a certain flow to kick in.
For example, most chatbots respond when you say hie
or start
or something similar. These are the
triggers
in JAWCE context. They not only work for "greeting" but are very powerful features that can boost your bot intelligence and UX.
Triggers are global, and they are evaluated first before any stages that you define in your templates
folder.
For example. Consider a trigger defined as below
"MAIN_MENU": "re:^start$"
The triggers above mean that, whenever user types start
- render the MAIN_MENU template to user
To define regex
triggers, always prefix them with re:
Learn more under Hooks section.
It's preferable to have your triggers as exact regex to avoid unexpected responses 😕.
Templates
Templates are predictable, are defined in "STAGES" or "STEPS" or "FLOW" whatever you want to call it, to make it easy to know where to go from 1 conversation to another.
There are a couple of hooks
you can define on your template - will cover hooks in the next section.
These hooks will extend the functionality of your template as you desire.
There are different message types in WhatsApp Message Types.
The engine supports a number of these official message types with the commons being:
- text
- button
- list
- flow
The engine can also handle dynamic and location message types
Let's look at examples