Capture information with input plugins

Last updated last month

So far, our content was limited to simple conversation. In a lot of use cases, you will need to ask the user for input. That input can then be stored in a database, for calling an API service, or for making personalised messages.

Adding an input plugin

In our Choo Choo example, our user has shown the intention to book a train ticket. Before we can do that, we need some information from the user like:

  • Origin

  • Destination

  • Departure time

  • First class or second class

Text input

Let's start by asking for the departure location.

  • Add a new bot dialog of type Input Validation by hovering over the + icon underneath the bot dialog book train ticket

  • Name this bot dialog Destination

  • Similarly add a new bot dialog Confirm booking with bot dialog Destination as parent

  • Click on the label of the bot dialog Destination, we will add content to this first.

  • Go to the Bot Message properties pane

  • Add a new text message with the text "Where do you want to go?"

The parent - child relation between dialog state nodes has no functional conversation meaning. It is only a visual representation.

Input plugins can automatically parse certain types of data like dates, addresses, numbers, hours, currency, ... This will convert the users response into a more structured format. We are simply asking for any string here, so we use input type 'Any' which will accept all values as valid input. More info about Plugin Parser Types

  • Type 'destination' as the variable.

  • Select 'Any' as the Input type.

  • Select 'Confirm booking' as the Next Dialog State

Using input in text messages

All the session variables are stored in the user session. To access a variable in any displayed text, you can put the variable name between curly brackets.

  • Go to the 'Confirm booking' bot dialog

  • Enter a new text message 'Okay you want to go to {destination}. We can do that.'

Linking bot dialogs

We have not defined an intent to get to the 'Origin' bot dialog. That makes sense as we only want to reach this state whenever we are in a specific part of the conversational flow: while booking train tickets. We want this input bot dialog to only be reachable as a next step when users have stated their intention to book a train ticket.

  • Edit the 'book train ticket' bot dialog.

  • Go to the Bot Messages properties pane

  • Click 'Add next bot dialog'

  • Choose the 'Origin' bot dialog from the drop down list.

If you forget to define the 'Go to' and you test your conversation flow, the flow will just stop. The conversation flow will only continue if you correctly set the 'Go to' on each dialog state.

Add remaining dialog states

Repeat the previous steps for each required user input variable.

Combining input plugins with buttons

In a previous example we requested user input by sending a text message but it is also possible to use buttons, lists, carousels and other UI components to support user input as text or clicks.

Let's use a carousel component to request the user his preferred train class.

  • Remove the text message in the bot dialog 'First or second class'.

  • Add an input plugin

  • Add a text message in this plugin

  • Add a Carousel and a Carousel Card for first and second class

  • Configure the button with a next dialog state 'Confirm Booking' and create a value 'first' for the variable 'class'.

It's important to use an identical variable name for the input variable, the NLP entity and the button variable.

Depending on the user input different actions are executed:

  1. When the user has defined an entity class in his sentence which had a book intention as result (for example: "i need a first class train ticket'), the 'class' variable is stored in the user session with a value 'first' and the bot dialog 'first or second class' is skipped because the value for the input variable is already available in the user session.

  2. When the user is asked to input his preferred train class and he inputs 'first', this value will be added in the input variable 'class' in the user session.

  3. When the user clicks the button 'First Class', the value 'first' will be added to the variable 'class' in the user session.

It also possible to define an extra intent 'Input train class' with expressions and entity values

  • i prefer first class

  • i would like to have a first class ticket

  • second class please

Linking this intent to the bot dialog 'First or second class' would support different sentences for preferred train class input.

As an alternative solution it is possible to request a custom parser for input plugins. You can request all kinds of input type parsers for parsing custom domain related data such as customer numbers, vehicle parameters, .... Please Get in contact with our Support team or your project manager for these requests.

In the next tutorial we will learn how we can use context for reusing intents. A good example are yes and no, which can be used in association with more than one specific dialog state.