Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Botframework 无法从Json文件获取自适应卡值_Botframework_Azure Bot Service_Adaptive Cards - Fatal编程技术网

Botframework 无法从Json文件获取自适应卡值

Botframework 无法从Json文件获取自适应卡值,botframework,azure-bot-service,adaptive-cards,Botframework,Azure Bot Service,Adaptive Cards,我有以下Json文件 { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.0", "body": [ { "type": "TextBlock", "size": "Medium", "weight": "Bolder", "text": "Customer Infor

我有以下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"
      }
    }
  ]
}
这是我的机器人输入表单:

当我尝试从turnContext检索值时,得到的值为空。请参阅下面的代码:

messageActivityAsync上的受保护覆盖异步任务(iTurContext turnContext,CancellationToken CancellationToken)
{
随机r=新随机();
var cardAttachment=CreateAdaptiveCardAttachment(_cards[r.Next(_cards.Length)]);
Wait turnContext.SendActivityAsync(MessageFactory.Attachment(cardAttachment),cancellationToken);
Wait turnContext.SendActivityAsync(MessageFactory.Text(“您的请求已提交,谢谢”),cancellationToken);
} 

我想我应该从turnContext活动中获得价值。但它看起来是空的。

请尝试下面的代码,从自适应卡中获取价值:

//Captature sumitted value
var txt = turnContext.Activity.Text;
dynamic val = turnContext.Activity.Value;

希望有帮助

你的意思是我应该在MessageActivityAsync的这个方法中这样做吗?是的。在OnMessageActivitySync中插入代码以获取自适应卡值