【发布时间】:2020-02-13 00:35:48
【问题描述】:
我有以下 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 中检索值时,我得到了 null 值。请看下面的代码:
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 活动中获得价值。但它看起来是空的。
【问题讨论】:
标签: botframework azure-bot-service adaptive-cards