1

我正在使用 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 表单的问题的答案发送到数据库,但到目前为止,我还没有找到这样做的方法。

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

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

4

1 回答 1

0

似乎是在我的项目中导致问题的原因是将此参数发送到函数:

GeneratedForm.BuildJsonForm(channel, user, convers);

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

GeneratedForm.BuildJsonForm();
于 2017-07-10T04:29:45.727 回答