gpt4 book ai didi

c# - 如何检测/监听来自自适应卡的 action.submit

转载 作者:行者123 更新时间:2023-11-30 22:57:52 27 4
gpt4 key购买 nike

我正在使用 botframework(企业机器人模板)和 LUIS.ai:

我的问题是,当我填写自定义自适应卡(它有三个文本输入字段)并单击“提交”时,我收到以下消息:“很抱歉,我无法提供帮助。”我可以在模拟器中看到提交按钮发回输入的值,但我不确定如何监听按钮操作。我的想法是我必须监听何时调用操作的 ID,但我我不完全确定如何做到这一点。

下面是调用对话框的代码:

    public static IMessageActivity SendTicketFormCard(ITurnContext turnContext, dynamic data)
{
var response = turnContext.Activity.CreateReply();
var introcard = File.ReadAllText(@".\dialogs\main\resources\Ticket_Fields.json");

response.Attachments = new List<Attachment>();
response.Attachments.Add(new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(introcard),
});

return response;
}

JSON 对话框如下所示:

{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"size": "Medium",
"weight": "Bolder",
"color": "Dark",
"text": "Search Ticket"
},
{
"type": "TextBlock",
"id": "94358428-5ef2-43a5-9056-d3cac1abfabd",
"text": "Ticket ID:",
"maxLines": 1
},
{
"type": "Input.Text",
"id": "68e1e180-4cdc-4ad6-bb8f-743554f1f58b",
"placeholder": "Ticket ID (required)",
"maxLength": 10
},
{
"type": "TextBlock",
"id": "2da1df9d-7f61-4e5c-9ff9-7aba2c5b306b",
"text": "Summary:",
"maxLines": 1
},
{
"type": "Input.Text",
"id": "403979a3-ccba-4baa-a885-2abca754cc69",
"placeholder": "Summary (optional)",
"maxLength": 250,
"isMultiline": true
},
{
"type": "TextBlock",
"id": "a25464c7-07ea-4270-995f-5e57b783b52d",
"text": "Status:",
"maxLines": 1
},
{
"type": "Input.Text",
"id": "7794d725-feb5-4516-9786-d18684892106",
"placeholder": "Status (optional)",
"maxLength": 30
}
],
"actions": [
{
"type": "Action.Submit",
"id": "783fe2e4-4056-449e-8cc6-5dc9c406222a",
"title": "Search"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}

最佳答案

当您单击自适应卡中的“提交”按钮时, channel 会在 channel 数据对象中发回“postback”:“true” token 。与此同时,在提交按钮上配置的数据也会在 json 的 Value 对象中发送。您需要解析此值以获取采取进一步操作所需的详细信息。我已经发表了一篇关于此的文章。请查看: BotFramework Reactive Adaptive Cards: How to Read Data on Action Buttons in Adaptive Cards

关于c# - 如何检测/监听来自自适应卡的 action.submit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53346478/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com