gpt4 book ai didi

c# - Action.Submit 不适用于机器人框架

转载 作者:行者123 更新时间:2023-12-03 04:02:18 26 4
gpt4 key购买 nike

Attached image is of bot emulator on clicking the submit button.

我使用以下代码创建了一张自适应卡。但是,单击提交按钮后,机器人会抛出错误。

var card = new AdaptiveCard();
card.Body.Add(new AdaptiveTextBlock() { Text = "May I know who I am chatting with?", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder, HorizontalAlignment = AdaptiveHorizontalAlignment.Left });
card.Body.Add(new AdaptiveImage() { UrlString = "https://media-exp1.licdn.com/dms/image/C510BAQHDcYycRMpKWQ/company-logo_200_200/0?e=2159024400&v=beta&t=MRb3ZSGGATtJvp6s6XQt3r_SqyhORkaleuB3bUWVe6g", Size = AdaptiveImageSize.Medium, HorizontalAlignment= AdaptiveHorizontalAlignment.Right }) ;
card.Body.Add(new AdaptiveTextBlock() { Text = "Name", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder });
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Text, Id = "Name", Placeholder = "First Last"});
card.Body.Add(new AdaptiveTextBlock() { Text = "Mobile number:", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder });
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Tel, Id = "Mobile number", Placeholder = "xxx.xxx.xxxx" });
card.Body.Add(new AdaptiveTextBlock() { Text = "Email:", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder });
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Email, Id = "Email", Placeholder = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c6573696e79717d75705c79647d716c7079327f7371" rel="noreferrer noopener nofollow">[email protected]</a>" });
card.Body.Add(new AdaptiveTextBlock() { Text = "Your Company Name:", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder});
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Text, Id = "Your Company Name" });
card.Body.Add(new AdaptiveTextBlock() { Text = "Message:", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder});
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Text, Id = "Message", IsMultiline = true });
card.Actions.Add(new AdaptiveSubmitAction() {Title = "Submit", Data = { } });

return new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};

最佳答案

这就是我创建自适应卡的方式-

public static Attachment PersonalInfo()
{
var card = new AdaptiveCard("1.0");

card.Body.Add(new AdaptiveTextBlock() { Text = "Sure. While I fetch that, may I know you a little?", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder, HorizontalAlignment = AdaptiveHorizontalAlignment.Left });
//card.Body.Add(new AdaptiveTextBlock() { Text = "If yes, please fill in the form below and click SUBMIT.", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder, HorizontalAlignment = AdaptiveHorizontalAlignment.Left });
//card.Body.Add(new AdaptiveTextBlock() { Text = "If no, please click CANCEL at the end", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder, HorizontalAlignment = AdaptiveHorizontalAlignment.Left });
//card.Body.Add(new AdaptiveChoiceSetInput() { Id = "Choose", Style = AdaptiveChoiceInputStyle.Expanded, Choices = new List<AdaptiveChoice>() { new AdaptiveChoice() { Title = "Yes", Value = "Yes" }, new AdaptiveChoice() { Title = "No", Value = "No" } } });
//card.Body.Add(new AdaptiveImage() { UrlString = "https://media-exp1.licdn.com/dms/image/C510BAQHDcYycRMpKWQ/company-logo_200_200/0?e=2159024400&v=beta&t=MRb3ZSGGATtJvp6s6XQt3r_SqyhORkaleuB3bUWVe6g", Size = AdaptiveImageSize.Medium, HorizontalAlignment= AdaptiveHorizontalAlignment.Right }) ;
//card.Body.Add(new AdaptiveTextBlock() { Text = "Name", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder });
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Text, Id = "Name", Placeholder = "Name", IsMultiline = true, IsRequired = true });
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Tel, Id = "Mobile number", Placeholder = "Mobile number", IsMultiline = true });
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Email, Id = "Email", Placeholder = "Email ID", IsMultiline = true, });
card.Body.Add(new AdaptiveTextInput() { Style = AdaptiveTextInputStyle.Text, Id = "Your Company Name", Placeholder = "Your Company Name", IsMultiline = true });
card.Actions.Add(new AdaptiveSubmitAction() { Title = "SUBMIT", Style = "positive", Id = "submit", Data = "submit", DataJson = "{\"submit\":\"submit\"}"});
card.Actions.Add(new AdaptiveSubmitAction() { Title = "CANCEL", Style = "negative", Id = "cancel", Data = "cancel", DataJson = "{\"cancel\":\"cancel\"}" });

return new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
}

然后在 OnTurnAsyc Activity 的开头-

if (string.IsNullOrEmpty(turnContext.Activity.Text))
{
dynamic value = turnContext.Activity.Value;
if (value != null)
{
if (value["submit"] == "submit")
{
//bool flag = true;
isFormSubmit = true;
string text = value["submit"]; // The property will be named after your text input's ID
text = string.IsNullOrEmpty(text) ? "." : text; // In case the text input is empty
turnContext.Activity.Text = text;
}
else if (value["cancel"] == "cancel")
{
isFormCancel = true;
string text = value["cancel"]; // The property will be named after your text input's ID
text = string.IsNullOrEmpty(text) ? "." : text; // In case the text input is empty
turnContext.Activity.Text = text;
}
}

}

关于c# - Action.Submit 不适用于机器人框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61675244/

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