簡體   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