concept dialog model in category alexa

This is an excerpt from Manning's book Voice Applications for Alexa and Google Assistant.
Figure 8.1 Flow of data in the dialog model
![]()
Whether a slot is elicited or confirmed, or an intent is confirmed, must be defined in the dialog model. The give and take that sees these steps through, however, can be handled in a few different ways. Alexa can handle the steps, or the fulfillment can, or both can in the same flow. The underlying principle of voice applications passing information back and forth between user and services remains, with potentially more round trips to gather the information and complete the user’s request.
We can let Alexa handle the dialog because at each step in the dialog, Alexa sends the fulfillment an intent request that also contains a property named
dialogState
. In figure 8.2, you see thedialogState
change as the dialog moves forward. Until every slot is filled and all information is confirmed,dialogState
will have a value other thanCOMPLETED
. The intent can check for the presence of this value and pass back control to Alexa if it’s not present. Alexa will use responses defined in the dialog model to speak to the user.Figure 8.2 The states of a dialog
![]()
Conversely, the fulfillment can handle this flow itself. This is not as taxing for the developer as using a developer-defined state would be, because the fulfillment continues to rely on
dialogState
and stays within a single intent. At each turn, the code determines if there’s a need to elicit a slot, ask for confirmation, or continue with the response. In this scenario the developer has more control, but it comes with the trade-off of more code. For example, Alexa will not use any of the responses defined in the dialog model, expecting the fulfillment to send them instead.
Listing 8.3 A
dialog
object in the interaction model (./models/en-US.json){ "interactionModel": { "languageModel": { ... }, "dialog": { #1 "intents": [ #1 { #1 "name": "BuyTicketsIntent", #1 "slots": [] #1 } #1 ] #1 }, #1 "prompts": [] } } #1 A new object to hold the dialog model