This template shows how to build a bot with deep flows, where users navigate a decision tree using interactive elements like buttons. This is useful when you want to guide the user through a conversation with predefined flows that consist of several steps. Examples of this type of bots include (but are not limited to):
- Pre-qualifiers of leads before human handoff
- On-boarding processes
- FAQs (when you have a very limited set of options)
In the same way you build a website with a deep tree of routes, in botonic you make use of
childRoutes to describe actions that are only accessible if the user is in the parent route.
With the following example you will get an idea of how
When the user starts the conversation the bot will ask whether he wants to eat pizza or pasta. You "force" the user to select either one by prompting two quick replies:
In the example, we have the option of pizza or pasta. This is where
childRoutes come in. Depending on the choice made, the chatbot will ask different things. When choosing pizza, the chatbot asks if you want sausage or bacon, while with pasta the chatbot will ask if you want cheese or tomato.
Because we are using
childRoutes, if you try to access the components of the ingredients directly you will not find them. Since the path to access is
hi -> pizza / pasta -> ingredient, it is guaranteed you can only choose the ingredient if you have chosen the food first.
In certain cases, it could be preferable to keep your 'routes.js' file as clean as possible. Let's take the previous example and replace the text attributes with payloads.
You can achieve the same flow's behaviour by preserving the parent of the previous flow and doing the following modifications in the corresponding action files:
Note that instead of a payload, you can use a path to trigger an action, for example
Working with URL Parameters
Since every action is linked in the same way as URLs, you can also pass them additional parameters to have a better control of your responses. So, the following piece of code will fill our
Then you can access its parameters in the following way in