我有以下Json文件
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Customer Information Form",
"horizontalAlignment": "Center"
},
{
"type": "Input.Text",
"placeholder": "First Name",
"style": "text",
"maxLength": 0,
"id": "SimpleVal",
"color": "Red"
},
{
"type": "Input.Text",
"placeholder": "Last Name",
"style": "Url",
"maxLength": 0,
"id": "UrlVal"
},
{
"type": "Input.Text",
"placeholder": "Company Name",
"style": "text",
"maxLength": 0,
"id": "companyname",
"color": "Red"
},
{
"type": "Input.Text",
"placeholder": "Email",
"style": "Email",
"maxLength": 0,
"id": "EmailVal"
},
{
"type": "Input.ChoiceSet",
"placeholder": "Country",
"id": "CompactSelectVal",
"value": "1",
"choices": [
{
"title": "Country",
"value": "1"
},
{
"title": "United States",
"value": "2"
},
{
"title": "Algeria",
"value": "3"
}
]
},
{
"type": "Input.Text",
"placeholder": "Phone Number",
"style": "Tel",
"maxLength": 0,
"id": "TelVal"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"data": {
"id": "1234567890"
}
}
]
}
这是我的Bot输入表:
当我尝试从 turnContext 检索值时,我得到了空值。请参见下面的代码:
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
Random r = new Random();
var cardAttachment = CreateAdaptiveCardAttachment(_cards[r.Next(_cards.Length)]);
await turnContext.SendActivityAsync(MessageFactory.Attachment(cardAttachment), cancellationToken);
await turnContext.SendActivityAsync(MessageFactory.Text("Your Request has submitted. Thank you"), cancellationToken);
}
我认为我应该从turnContext活动中获得价值。但它看上去是空的。
答案 0 :(得分:1)
尝试以下代码从自适应卡中获取价值:
//Captature sumitted value
var txt = turnContext.Activity.Text;
dynamic val = turnContext.Activity.Value;
希望有帮助!