【发布时间】:2019-09-01 12:05:20
【问题描述】:
我在 LUIS 中设置了一些意图,当机器人被问到问题时,它们可以完美地工作。我想将其中一些问答转换为自适应卡。目前我能够实现这样的目标:
如果我点击下面的任何问题,回复就会显示在卡片中,而不是机器人的回复。
这是我的 JSON(仅相关部分):
"actions": [
{
"type": "Action.Submit",
"title": "About ",
"data": {
"action": "about"
}
},
{
"type": "Action.ShowCard",
"title": "FAQs",
"card": {
"type": "AdaptiveCard",
"style": "emphasis",
"actions": [
{
"type": "Action.ShowCard",
"title": "When are you open?",
"card": {
"type": "AdaptiveCard",
"style": "emphasis",
"body": [
{
"type": "TextBlock",
"text": "We are open from Monday through Friday from 8:00am to 6:00pm.",
"wrap": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.ShowCard",
"title": "Do you have an office near me? ",
"card": {
"type": "AdaptiveCard",
"style": "emphasis",
"body": [
{
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://i.imgur.com/gBVgI25.png",
"size": "Stretch"
},
{
"type": "TextBlock",
"text": "AZ, CA, CO, FL, GA, HI, NC, NV, OR, SC, TN, TX, UT, VA & WA",
"wrap": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.ShowCard",
"title": "How quickly can we close? ",
"card": {
"type": "AdaptiveCard",
"style": "emphasis",
"body": [
{
"type": "TextBlock",
"text": "8 to 10 days, it all depends on how it takes to get access to the property.",
"wrap": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
]
这是我的代码:
protected async Task<DialogTurnResult> BeginChildDialogAsync(DialogContext dc, OnTurnProperty onTurnProperty)
{
var activity = dc.Context.Activity;
var actionValue = onTurnProperty.Intent;
switch (onTurnProperty.Intent)
{
case "Greeting":
await dc.Context.SendActivityAsync("Hello there!");
return new DialogTurnResult(DialogTurnStatus.Empty);
break;
case "LendingStates":
await dc.Context.SendActivityAsync("AZ, CA, CO, FL, GA, HI, NC, NV, OR, SC, TN, TX, UT, VA & WA");
return new DialogTurnResult(DialogTurnStatus.Empty);
break;
case "CloseCase":
await dc.Context.SendActivityAsync("8 to 10 days, it all depends on how long it takes to get access to the property.");
return new DialogTurnResult(DialogTurnStatus.Empty);
break;
case MenuDialog.Name:
// todo: need to implement this one
return await dc.BeginDialogAsync(MenuDialog.Name);
break;
break;
default:
await dc.Context.SendActivityAsync($"I don't know how to handle the action \"{actionValue}\"");
return new DialogTurnResult(DialogTurnStatus.Empty);
}
return new DialogTurnResult(DialogTurnStatus.Empty);
}
此时我不确定如何更改我的 JSON 或代码,以便如果用户单击自适应卡上的选项,它会在我的代码中匹配正确的大小写。如果我不使用该卡并问机器人“你什么时候开门?”直接,我得到了正确的答复。
【问题讨论】:
标签: c# botframework