我正在使用函數BuildJsonForm爲define a form using a JSON schema。我使用bot在運行時詢問用戶的一些參數來生成JObject。Bot框架 - 從json模式生成的表單獲取用戶的答案
的JObject/JSON我發送到功能BuildJsonForm的一個例子是這樣的一個:
`
{
"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,這樣我就可以直接從「OnCompletion」的JSON的部分發送用戶的回答到數據庫中,但我仍然似乎無法訪問到botdata或OnCompletion部分的上下文。
是否有任何其他方式可以在用戶回答表單中的最後一個問題後成功檢索用戶對JObject/JSON生成表單的響應?
也許上下文在此處不可用。 –
這就是我最初的想法,但OnCompletion中的命令'await context.PostAsync(\「Thank you!\」);'(這也是您可用於在對話框代碼中的通道中發佈bot消息的行)有它的背景。我也嘗試訪問onCompletion中的bot數據並得到了異常,現在無論我做什麼,我都會得到相同的異常,即使使用過去完美工作的JSON。 – maria