我正在使用botbuilder自适应对话框的预览来收集一些用户信息。我想将此信息存储在SQL中。所以我的问题是如何从文本输入中的“属性”中收集信息?
new TextInput
{
Prompt = new ActivityTemplate(question.Text),
Property = "user.userProfile" + question.Id
}
答案 0 :(得分:2)
使用CodeAction或HttpRequest调用您的api来存储信息
使用它向任何端点发出HTTP请求。
new HttpRequest()
{
// Set response from the http request to turn.httpResponse property in memory.
ResultProperty = "turn.httpResponse",
Method = HttpRequest.HttpMethod.POST,
Headers = new Dictionary<string,string> (), /* request header */
Body = JToken.FromObject(new
{
data = "@{user.userProfile" + question.Id + "}",
another = "@{user.another}"
}) /* request body */
});
代码操作
private async Task<DialogTurnResult> CodeActionSampleFn(DialogContext dc, System.Object options)
{
var userState = JObject.FromObject(dc.GetState().FirstOrDefault(x => x.Key == "user").Value);
//Get your data here
var data = userState.Value<JObject>("userProfile" + question.Id);
// call your API by HttpClient
//...
return dc.ContinueDialogAsync();
}
答案 1 :(得分:1)
您可以看到有关如何在上访问state properties的示例:
new SendActivity("Hello, @{user.name}")