繁体   English   中英

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

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

我正在使用BuildJsonForm函数来使用JSON模式定义表单 我用运行时机器人向用户询问的一些参数生成了JObject。

我发送给函数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...]"

}

`

我需要将用户对生成的JObject / JSON表单的问题的答案发送到数据库,但是到目前为止,我还没有找到一种解决方法。

我还尝试使用此行context.PrivateConversationData.TryGetValue<string>("Files", out files);访问BotData context.PrivateConversationData.TryGetValue<string>("Files", out files); ,因此我可以直接从JSON的“ OnCompletion”部分将用户的答案发送到数据库,但仍然似乎无法访问OnCompletion部分的botdata或上下文。

在用户回答表单中的最后一个问题之后,还有其他方法可以成功检索用户对JObject / JSON生成的表单的响应吗?

似乎是在我的项目中引起麻烦的是将以下参数发送给函数:

GeneratedForm.BuildJsonForm(channel, user, convers);

因为我没有这些参数就编辑了函数,并且我停止获取问题中指定的异常。 我将寻找这些参数导致问题的原因,但是在这种情况下,我发现的解决方案是通过以下方式定义功能:

GeneratedForm.BuildJsonForm();

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM