Search code examples
dialogflow-cx

Issues with State/Pages


I'm having an issue with my bot changing an unexpected page. For example, I have a sample application where you order a pizza. It goes like this:

  1. "I want to order a pizza."
  2. Pick your toppings
  3. Pick your type of crust
  4. Speak any special requests (light on the cheese, etc.)

I want to make sure that when the user is on a specific page that it won't jump back to a different page. If it asks me what type of crust I want on my pizza, and I say "pepperoni," it should trigger a "no match," but instead it jumps back to #2, assuming that I am picking my toppings. It shouldn't go back; the topping has already been chosen. With Dialogflow ES I could prevent this from happening by marking the intent with a specific context, but I don't know how to prevent that from happening in Dialogflow CX.

How do I keep the bot on the right path without the user being able to jump around the flow by saying something unexpected? Any help is appreciated.


Solution

  • You say that the issue you're describing only happens in the Start page. That happens because the Start page is not a real page at all.

    I suggest you take a look at the documentation, specifically to scoping routes and handlers. If you use the API, the Start page's routes and handlers actually represent the flow's routes and handlers. So if you specify a route (an intent or condition which maps to a transition) in the Start page, that route will be accessible from the whole flow. At any given point inside of a flow, any and all routes available in the Start page are also available (or in scope) in the following pages of the same flow.

    To work around the issue I suggest you place a route in the start page which has a custom condition of true (will always occur when you're in the start page) and a transition to a "Start order" page. From this point use the builder as you've already done, build the next pages with the parameters and intents you're using. With this workaround, each page only allows the transitions specified in that specific page and you can restrict the intents available.