简体   繁体   English

Bot框架-从JSON模式生成的表单中获取用户的答案

[英]Bot framework - Getting the user's answers from a form generated by json schema

I am using the function to BuildJsonForm to define a form using a JSON schema . 我正在使用BuildJsonForm函数来使用JSON模式定义表单 I generate the JObject with some parameters the bot asks the user during runtime. 我用运行时机器人向用户询问的一些参数生成了JObject。

An example of the JObject/JSON I send to the function BuildJsonForm is this one: 我发送给函数BuildJsonForm的JObject / JSON的示例如下:

` `

  {
    "References": [
      "Microsoft.Bot.Connector.dll",
      "System.dll",
      "mscorlib.dll",
      "System.Net.Http.dll"
    ],
    "Imports": [
      "Microsoft.Bot.Connector.ThumbnailCard",
      "Microsoft.Bot.Connector.StateClient",
      "System.Net.Mail",
      "System",
      "System.Text.RegularExpressions",
      "System.Net.Http",
      "System.Net",
      "System.Text"
    ],
    "type": "object",
    "required": [
      "username",
      "password"
    ],
    "Templates": {
      "NotUnderstood": {
        "Patterns": [
          "I do not understand, Please rephrase that"
        ]
      },
      "EnumSelectOne": {
        "Patterns": [
          "Choose one please"
        ],
        "ChoiceStyle": "Auto"
      }
    },
    "properties": {
      "username": {
        "Prompt": {
          "Patterns": [
            "Tell me the {&}, please",
            "I need you to especify a {&}, please"
          ]
        },
        "type": [
          "string",
          "null"
        ],
        "Templates": {
          "NotUnderstood": {
            "Patterns": [
              "That is not a valid input"
            ]
          }
        }
      },
      "password": {
        "Prompt": {
          "Patterns": [
            "Tell me the {&}, please",
            "I need you to especify a {&}, please"
          ]
        },
        "type": [
          "string",
          "null"
        ],
        "Templates": {
          "NotUnderstood": {
            "Patterns": [
              "That is not a valid input"
            ]
          }
        }
      }
    },
    "OnCompletion": "await context.PostAsync(\"Thank you!\"); string files = \"\"; context.PrivateConversationData.TryGetValue<string>(\"Files\", out files); [more code...]"

}

` `

I need to send to the database the user's answers to the generated JObject/JSON form's questions, but so far, I haven't found a way to do that. 我需要将用户对生成的JObject / JSON表单的问题的答案发送到数据库,但是到目前为止,我还没有找到一种解决方法。

I also tried accessing the BotData with this line context.PrivateConversationData.TryGetValue<string>("Files", out files); 我还尝试使用此行context.PrivateConversationData.TryGetValue<string>("Files", out files);访问BotData context.PrivateConversationData.TryGetValue<string>("Files", out files); , so I could send the user's answers to the database directly from the "OnCompletion" section of the JSON, but still I can't seem to access to the botdata or context on the OnCompletion section. ,因此我可以直接从JSON的“ OnCompletion”部分将用户的答案发送到数据库,但仍然似乎无法访问OnCompletion部分的botdata或上下文。

Is there any other way I can successfully retrieve the user's responses to the JObject/JSON generated form after the user answers the last question in the form? 在用户回答表单中的最后一个问题之后,还有其他方法可以成功检索用户对JObject / JSON生成的表单的响应吗?

It seemed that what was causing the trouble in my project were sending this parameters to the function: 似乎是在我的项目中引起麻烦的是将以下参数发送给函数:

GeneratedForm.BuildJsonForm(channel, user, convers);

since I edited the function without those parameters and I stopped getting the exception specified in the question. 因为我没有这些参数就编辑了函数,并且我停止获取问题中指定的异常。 I will look for the reason these parameters were causing problems but the solution I found in this case was to define the funtction this way: 我将寻找这些参数导致问题的原因,但是在这种情况下,我发现的解决方案是通过以下方式定义功能:

GeneratedForm.BuildJsonForm();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Bot Framework Form Builder C#,在构建表单之前获取用户输入 - Microsoft Bot Framework Form Builder C#, Getting User input before building the form Microsoft Bot Framework JSON数据未获取 - Microsoft Bot Framework JSON Data Not Getting Bot框架-动态FormFlow取决于先前的答案 - Bot Framework - Dynamic FormFlow Depending on previous Answers Bot应用程序无法使用其他用户角色(Microsoft Bot Framework) - Bot app not working from another User Role (Microsoft Bot Framework) 使用Microsoft Bot Framework检索用户的Skype头像和个人资料 - Retrieve user's Skype avatar and profile with Microsoft Bot Framework 为什么“全部”从Bot Framework的枚举列表中删除 - Why is 'All' getting removed from my enum list in Bot Framework 是否可以像从用户那里一样向Bot Framework发送消息? - Is it possible to send a message to the Bot Framework as if it were from the user? 如何使用 C# 中的 Bot Framework 从用户那里接收附件? - How to receive attachments from a user with Bot Framework in C#? 使用Bot框架C#从用户保存上传的文件 - Saving uploaded file from user with bot framework c# Microsoft Bot Framework-如何从团队渠道获取用户数据 - Microsoft Bot Framework - How to get user data from team channel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM