我正在尝试让下面的示例机器人运行。
https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/adaptive-dialog/csharp_dotnetcore/04.core-bot
我可以使用Bot Framework Emulator成功地运行它并连接到它。
以下对话有效:
预订航班
- 您的出发城市是什么
迈阿密 - 你想去哪里旅行
dallas - 你的出发日期是几号
明天 - 你觉得这听起来合适吗?我让你从迈阿密前往达拉斯,时间:2020-03-13
是的 - 我已经为你预订了2020-03-13从迈阿密到达拉斯的机票
问题是当我试图预订航班并同时提供城市时
"预订从迈阿密起飞的航班"-你的出发城市是什么?
我的理解是,机器人应该将迈阿密实体识别为出发城市,然后询问目的地城市。
我相信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和来自City的实体识别为迈阿密
{
"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((操作可以被删除,机器人程序仍然可以正常工作。这个示例机器人程序适用于其他人吗?我错过了什么?
如有任何帮助,我们将不胜感激。
识别的实体似乎存储在一个数组中,需要通过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"
},
目的地城市也是如此
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?
(迈阿密被存储为出发城市,稍后使用,目的地城市是的提示(
我不能说这在所有情况下都有效,因为我不确定数据模型,但它似乎确实修复了样本,可能应该更新。
btw-Botframework对话框调试器可以帮助调试。
https://marketplace.visualstudio.com/items?itemName=tomlm.vscode-对话框调试器