Now, our agent has asked the user how many toppings they want on their pizza. There are three possible responses to this: none, one, or two. We will need to create an intent for each of these responses, as each intent will have contain a different number of parameters.
- Create a new intent for each of the possible number of toppings desired, called toppings.none, toppings.one, and toppings.two
We will look at how to create the intent toppings.one, and you should have the tools to be able to create toppings.none and toppings.two on your own.
- Create a new intent, name it toppings.one, define topic as Pizza Order
- Enter 5 user expressions in Expressions
- Add a new parameter named TOP_ONE, choose the entity @sys.any
- Check Required
- In Prompts, enter the phrase “Okay, what topping would you like?”
- Add a new parameter named DRINK, choose the entity @sys.any
- Check Required
- In Prompts, enter the phrase “Something to drink?”
- Save the intent toppings.one
We should create entities to validate the values the user provides for toppings and for drinks.
- Create entities called toppings and drinks, and enter in possible values and their synonyms.
- Go back to the intent toppings.one, and select the correct entities within the appropriate parameters
- Create an additional prompt variant preceded by an asterisk to prompt the user to provide a valid answer
NOTE: Adding in multiple prompt variants or responses generally will cause the agent to choose randomly between the options. If a prompt is preceded by an asterisk (*), it will serve as a secondary prompt, which the agent will use only after not attaining a required parameter.
Now, we want the final response of the toppings.one intent (as well as the toppings.none and toppings.two intents) to sum up the order until this point. We can use parameters that we’ve already collected in an agent’s response by representing the parameter with its exact name preceded by a dollar sign.
- In Responses, enter the phrase “Awesome. To sum up: we’ve got one $SIZE pizza with $TOP_ONE and $DRINK. Will that be cash or credit?”
- Test your agent in the simulator.
You will (hopefully) notice that something is wrong — the bot is able to return the values for the topping and for the drink parameters, but not the size, even though we’ve already asked the user the size.
The agent isn’t able to import the value for SIZE because that parameter was obtained in a different intent, unlike TOP_ONE and DRINK. How do we tell the agent to take that value from a different intent?