1
votes

I am trying to get the following sample bot working.

https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/adaptive-dialog/csharp_dotnetcore/04.core-bot

I can run it and connect to it using Bot Framework Emulator successfully.

The following conversation works:

Book flight

  • What is your departure city?
    miami
  • Where would you like to travel to?
    dallas
  • What is your departure date?
    tomorrow
  • Does this sound righ to you? I have you traveling to: dallas from: miami on: 2020-03-13
    yes
  • I have you booked to dallas from miami on 2020-03-13.

The problem is when I try to book a flight AND provide a city at the same time

"book flight from miami" - What is your departure city?

My understanding is the bot should recognize the entity miami as a departure city and then ask for the destination city.

I believe the RootDialog.cs file (I am using straight from sample) uses SetProperty() in the Book_flight intent to accomplish this.

https://github.com/microsoft/BotBuilder-Samples/blob/master/experimental/adaptive-dialog/csharp_dotnetcore/04.core-bot/Dialogs/RootDialog.cs

I thought the SetProperty() action would store the entity

Value = "@fromCity.location"

in the property

Property = "conversation.flightBooking.destinationCity"

Subsequently, the TextInput would use the prompt

Prompt = new ActivityTemplate("@{PromptForMissingInformation()}")

which reads in the RootDialog.lg file

https://github.com/microsoft/BotBuilder-Samples/blob/master/experimental/adaptive-dialog/csharp_dotnetcore/04.core-bot/Dialogs/RootDialog.lg

# PromptForMissingInformation
- IF: @{conversation.flightBooking.departureCity == null} 
  - @{PromptForDepartureCity()}
- ELSEIF: @{conversation.flightBooking.destinationCity == null}
  - @{PromptForDestinationCity()}
- ELSEIF: @{conversation.flightBooking.departureDate == null}
  - @{PromptForTravelDate()}
- ELSE: 
  - @{ConfirmBooking()}

This should NOT prompt for departure city if it was already provided/stored.

I also looked at the results returned from LUIS using LUIS trace in Bot Framework Emulator. LUIS appears to correctly identify the intent Book_flight AND the entity fromCity as miami

{
  "recognizerResult": {
    "alteredText": null,
    "entities": {
      "$instance": {
        "fromCity": [
          {
            "endIndex": 22,
            "startIndex": 17,
            "text": "miami",
            "type": "builtin.geographyV2.city"
          }
        ]
      },
      "fromCity": [
        {
          "location": "miami",
          "type": "city"
        }
      ]
    },
    "intents": {
      "Book_flight": {
        "score": 0.941154063
      }
    },
    "text": "book flight from miami"
  }
}

Why is SetProperty() not saving the fromCity entity information? The 3 SetProperty() actions can be removed and the bot still works the same. Does this sample bot work for other people? What am I missing?

Any help would be appreciated.

1

1 Answers

0
votes

It appears the recognized entities are stored in an array and need to be accessed via the long form in the Value expression of the SetProperty() Action.

new SetProperty()
{

     Property = "conversation.flightBooking.departureCity",
     // Value is an expresson. @entityName is short hand to refer to the value of an entity recognized.
     // @xxx is same as turn.recognized.entities.xxx
     //Value = "@fromCity.location"                                
     Value = "turn.recognized.entities.fromCity[0].location"
},

the same for destinationCity

Value = "turn.recognized.entities.toCity[0].location"

and departureDate

Value = "turn.recognized.entities.datetime[0].timex[0]"

These changes allow the entities to be stored and NOT asked for if they are provided in original message. For example,

Book flight from miami
- Where would you like to travel to? 

(miami is stored as departureCity and used later, destination city is prompter for)

I can't say this will work in all situations as I'm not sure of the data model, but it does seem to fix the sample, which should probably be updated.

btw - Botframework Dialog Debugger does help with debugging.

https://marketplace.visualstudio.com/items?itemName=tomlm.vscode-dialog-debugger