[英]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.