Step 3: Design your dialog

All applications start with a component called Main, which typically covers greeting the user and asking what they would like to do. In the previous section, you created one intent, ORDER_COFFEE, and the corresponding intent component, also called ORDER_COFFEE. Now we’re about to build the main dialog flow for our coffee shop application, in which we will:

  • Greet the user: Add a message node, with a welcome message.
  • Collect the user intent: Add a question and answer node to ask the user what they would like to do, and an intent mapper node to direct the dialog flow to the appropriate intent component.
  • Say goodbye to the user: Configure what will happen when the dialog flow returns from the intent component. In this simple scenario we’ll add another message node and an external actions node to end the conversation.

Once we’re done, the component called Main will look like this:

  Graph for the top level of the coffee shop dialog design  

After that we’ll build the dialog flow for the ORDER_COFFEE intent component, which will perform these tasks:

  • Fulfill the intent: Add a question router node, to handle all required pieces of information, that is, the COFFEE_TYPE and COFFEE_SIZE entities. We’ll add a question and answer node for each entity directly from the question router node.
  • Collect entities: In each question and answer node, add a message to ask for information specific to the entity it’s meant to collect, and set a transition back to the question router node. The question router node and the associated question and answer nodes work together until all information has been collected.
  • Wrap up: Determine what to do once all information has been collected. We’ll add a message node directly from the question router node, summarize the order we receiver from the user, and return to the main dialog flow.

Once we’re done, the ORDER_COFFEE intent component called will look like this:

  Graph for the intent component that handles coffee orders in the coffee shop dialog design  

Greet the user

  1. Drag a Message node from the palette onto the Start node on the canvas.
    This automatically connects the Start node to the message node.

    The properties for this message node appear in the Node properties pane.
  2. Click the default node name, Message, at the top of the Node properties pane, and replace it with a unique name (see Naming guidelines)—for example, Welcome.
  3. Click the message placeholder.
    The message editor appears.
  4. In the field for the TTS output modality, enter the desired greeting message—for example, Welcome to My Coffee Shop!
    This automatically generates a message ID, based on the message text.
  5. Click outside the editor to close it.
    The message appears on the Welcome node.

Collect the user intent

  1. Drag a Question & Answer node from the palette onto the GoTo area of the Welcome message node.
    This automatically connects the message node to the question and answer node.
  2. (Optional) In the properties for the Welcome node, click the compact GoTo, to open the GoTo editor, and then replace the default GoTo transition label, with Always, to make it more obvious that this transition is not conditional.
    Notice the GoTo node field already indicates that the question and answer node is the next node in this flow.
  3. Click the question and answer node on the canvas.
    The properties for this node appear in the Node properties pane.
  4. Replace the default node name, Question & Answer, with a unique name—for example, Get Intent.
  5. Click + Message.
    A message placeholder appears.
  6. Click the message placeholder.
    The message editor appears.
  7. In the field for the TTS output modality, enter the desired question—for example, How can I help you today?
  8. Click outside the editor to close it.
    The question appears on the Get Intent node.
  9. Expand User input and click Collect.
  10. Expand the selector, point to Collect Intent, and choose NLU for your project.
  11. Click Add intent mapper node.

    This automatically connects the Get Intent question and answer node to an intent mapper node.
    Notice the intent mapper node indicates: 1 Mapped Component. This corresponds to the ORDER_COFFEE intent you defined earlier, in the NLU resource panel.
  12. Expand System actions and click Default.
    Notice the compact GoTo already indicates that the intent mapper node is the next node in this flow.
  13. (Optional) Click the compact GoTo, to open the GoTo editor, and then replace the default GoTo transition label, with Always, to make it more obvious that this transition is not conditional.

Say goodbye to the user

  1. Click the intent mapper node on the canvas.
    The properties for this node appear in the Node properties pane.
  2. Click the GoTo placeholder.
    The GoTo editor appears.
  3. Expand the GoTo node list, point to Add new, and choose Message.
    This automatically connects the intent mapper node to a message node.
    This transition determines what happens when the dialog returns to this intent mapper node from an intent component, after the interaction associated with a specific intent is complete.
  4. Click the Message node on the canvas.
  5. Replace the default name of the message node with a unique name—for example, Goodbye.
  6. Click the message placeholder.
    The message editor appears.
  7. In the field for the TTS output modality, enter the desired parting message—for example, Thanks for visiting My Coffee Shop. Goodbye.
  8. Click outside the editor to close it.
    The message appears on the Goodbye node on the canvas.
  9. Click the GoTo placeholder.
    The GoTo editor appears.
  10. Expand the GoTo node list, point to Add new, and choose External Actions.
    This automatically connects the Goodbye node to an external actions node.
  11. (Optional) On the canvas, double-click the GoTo area of the Goodbye node, and replace the default GoTo transition label, with Always.
  12. Click the external actions node.
  13. Replace its default name with a unique name—for example, End.
  14. Under Action type, choose End.

    The End node represents the end of the conversation.

Fulfill the intent

  1. In the Components pane, click your ORDER_COFFEE intent component.
  2. Drag a Question Router node from the palette onto the canvas.
    The properties for the question router node appear in the Node properties pane.
  3. Replace the default node name, Question Router, with a unique name—for example, Get Order Details.
  4. Under Route to questions, click + Collect Entity.
    A Collect placeholder appears.
  5. Click the placeholder.
    An editor appears.
  6. Expand the Entity list, and choose the first piece of information to be collected—COFFEE_TYPE, in this scenario.
  7. Expand GoTo node, point to Add new, and choose Question & Answer.
    This connects the question router node to a new question and answer node named after the entity to collect.
  8. Click outside the editor to close it.
    On the canvas, notice that Get Order Details is now connected to the question and answer node named COFFEE_TYPE.
  9. In the Node properties pane, click the Add icon , below the compact Collect parameter.
  10. Proceed in the same fashion (from step 5 above) to add another question and answer node for the remaining piece of information to be collected—that is, the COFFEE_SIZE entity.

Collect entities

  1. Click the COFFEE_TYPE question and answer node.
    The properties for this node appear in the Node properties pane.
  2. Click + Message.
    A message placeholder appears.
  3. Click the message placeholder.
    The message editor appears.
  4. In the field for the TTS output modality, enter the desired question—for example, What would you like to drink?
  5. Expand User input and click Collect.
    Notice the entity to collect, its data type, and the advanced settings are as expected (since this scenario doesn’t require the dialog flow to take different paths depending on the collected value, the Show in Actions switches are all turned off).
  6. Expand System actions and click View all.
  7. Under COFFEE_TYPE (Default), click the GoTo placeholder.
    The GoTo editor appears.
  8. Expand the GoTo node list, point to Return to, and choose Get Order Details.

    This means that, once the question and answer node has collected information relevant to the active intent—that is, any entities required to fulfill the intent—the dialog flow goes back to the question router node. The question router node determines whether information still remains to be collected.
    A symbol representing the Return to transition appears next to the transition label on the COFFEE_TYPE node.
  9. Configure the COFFEE_SIZE question and answer node in the same fashion:
    1. Add a question—for example, What size would you like?
    2. Set a Return to transition to return to the Get Order Details question router node.

Wrap up

  1. Click the Get Order Details question router node on the canvas.
  2. In the Node properties pane, under GoTo when questions are completed, click the GoTo placeholder.
    The GoTo editor appears.
  3. Expand the GoTo node list, point to Add new, and choose Message.
    This connects the question router node to a new message node.
  4. Click the new message node on the canvas.
  5. Replace the default name of the message node with a unique name—for example, Wrap Up.
  6. Click the message placeholder. The message editor appears.
  7. In the field for the TTS output modality, enter the desired message—for example, Your coffee is coming right up!
    The message appears on the Wrap Up node on the canvas.
  8. Click the GoTo placeholder.
    The GoTo editor appears.
  9. Expand the GoTo node list, and choose Return.

    When the dialog reaches this node, all interaction associated with the ORDER_COFFEE intent is complete and the dialog returns to the intent mapper node in the component from where this intent component was called.
    A symbol representing the Return transition appears next to the GoTo label on the Wrap Up node.