【问题标题】:Why doesn't botframework experimental adaptive corebot C# sample SetProperty() save entities returned by LUIS?为什么 botframework 实验性自适应 corebot C# 示例 SetProperty() 不保存 LUIS 返回的实体?
【发布时间】:2020-03-12 11:51:28
【问题描述】:

我正在尝试使以下示例机器人正常工作。

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

我可以运行它并使用 Bot Framework Emulator 成功连接到它。

以下对话有效:

预订航班

  • 您的出发城市是?
    迈阿密
  • 您想去哪里旅行?
    达拉斯
  • 您的出发日期是什么时候?
    明天
  • 这听起来对您来说是正确的吗?我有你前往:达拉斯,出发地:迈阿密:2020-03-13
    是的
  • 我已为您预订了 2020 年 3 月 13 日从迈阿密飞往达拉斯的机票。

问题是当我尝试预订航班并同时提供城市时

“从迈阿密预订航班” - 你的出发城市是?

我的理解是机器人应该将实体 miami 识别为出发城市,然后询问目的地城市。

我相信 RootDialog.cs 文件(我直接使用示例)在 Book_flight 意图中使用 SetProperty() 来完成此操作。

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

我认为 SetProperty() 操作会存储实体

Value = "@fromCity.location"

在属性中

Property = "conversation.flightBooking.destinationCity"

随后,TextInput 将使用提示符

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

读取 RootDialog.lg 文件

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()}

如果已经提供/存储了出发城市,则不应提示它。

我还使用 Bot Framework Emulator 中的 LUIS 跟踪查看了从 LUIS 返回的结果。 LUIS 似乎正确地将意图 Book_flight 和实体 fromCity 识别为 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"
  }
}

为什么 SetProperty() 不保存 fromCity 实体信息?可以删除 3 个 SetProperty() 操作,机器人仍然可以正常工作。这个示例机器人是否适用于其他人?我错过了什么?

任何帮助将不胜感激。

【问题讨论】:

    标签: c# json botframework chatbot azure-language-understanding


    【解决方案1】:

    识别出的实体似乎存储在一个数组中,需要通过 SetProperty() Action 的 Value 表达式中的长格式进行访问。

    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"
    },
    

    destinationCity 也一样

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

    和出发日期

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

    这些更改允许存储实体,并且不会在原始消息中提供实体时询问它们。例如,

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

    (迈阿密存储为departmentCity,稍后使用,目的地城市提示)

    我不能说这适用于所有情况,因为我不确定数据模型,但它似乎修复了示例,可能应该更新。

    btw - Botframework 对话框调试器确实有助于调试。

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

    【讨论】:

    • 如果可以接受,请接受您自己的答案,如果您想进行更改,请在相应的 GitHub 存储库中发布
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-19
    • 1970-01-01
    • 2019-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多