The Narrative is the bot-driven part of your app, typically starting with a greeting and ending with a goodbye. Each item in the Narrative is a bot turn. The bot turns will normally be executed in order from top to bottom.
This show an example of a Narrative with three bot turns:
Types of bot turns
Bot turns comes in three variants;
- Reply: this is an output only bot turn
- Request: this is a bot turn which is followed by a user turn (named from requesting something from the user)
- Bridge: this is a bot turn which is followed by another bot turn
You select the type of each bot-turn with the dropdown menu - the block will change shape accordingly:
Hello world - a first bot turn
The Narratory example of Hello world is a narrative with a single bot turn of type reply:
If you supply more than one text-block, Narratory will randomly pick one of them:
We recommend adding a few different variants to every bot output since repetition can bore and irritate users.
Request - Adding user input
The next step is to add answers to our bot turn. To do this, we change the type of our bot turn block to request and add one or several user turns to our bot turns's user input as shown here:
Each UserTurn takes two inputs, an intent (see NLU / Intents docs to learn how to create intents) containing example phrases of what the user can say to trigger this UserTurn, and one or several followup BotTurns.
Here we have added two user-turns, one triggered by the user saying "yes" and one for the user saying "no".
Combining turns to sub-dialogs
You can combine bot turns and user turns creating sub-dialogs like shown here:
Note We strongly recommend to not build sub-dialogs with a depth larger than the above since it quickly can become overwhelming to navigate. Instead, we recommend splitting large sub-dialogs into separate bot initiatives and using goto (see the next section on Jumping in narrative) to navigate between them.
Jumping in narrative
The bot turns in your narrative will execute in order, but you can use goto parameter to jump to any part in the narrative.
Here is an example where goto is used to jump to a different part of the narrative (talking about the weather) instead of going to the next bot turn in the narrative which would be a trivia game.
Conditional bot turns
Conditions are an essential part in making your dialog customized for the user. In your narrative, it is common to sometimes skip bot initiatives if some criteria is met. One example could be a bot initiative asking a user what color they want for a shirt they are buying. You likely only want to ask this question if the user hasn't already said what color he/she prefers, and if he/she actually is interested in buying a shirt.
Read how to implement conditions on bot turns in Logic docs.
The third type of bot-turn (aside from reply and request) is a bridge turn which allows you to have a bot-turn immidiatelly following another bot-turn. There are many cases where this is preferred:
- When you want to separate a long message into several shorter messages. This is important specifically for graphical chats where you might want to divide a long message into several "message bubbles" and you can't or don't want to create individual bot-initiatives for them - for example if you are in a sub-dialog as shown here:
- When you want to branch (i.e go to a different part of your dialog) based on a variable:
- When you want to use conditionals depending on the outcome of a webhook call and when it is not enough to do conditional says - for example because you want to use a goto in one of the cases.