Templates
ChatBot conversation flows
Templates are the building blocks of WCE. They define the brains, conversation flow which the bot respond to the user.
The engine uses 2 important folders which are the templates
folder and a triggers
folder.
Let's look at the contents of these folders in detail
WCE files are all *.yaml
files
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 WCE 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 trigger above mean that, whenever user types start
- render the MAIN_MENU template to the user
To define regex
triggers, always prefix them with re:
Learn more under Hooks section.
It's advised to have your triggers as exact regex to avoid unexpected responses 😕.
Templates
This folder houses all your chatbot conversation flows. 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 common ones being:
- text
- button
- list
- flow
- media
The engine can also handle dynamic and location message types
Let's look at examples