Rocco
Rocco

Reputation: 477

Botbuilder adaptive dialog storing user input

I'm using previews of the botbuilder adaptive dialog to gather some user info. I want to store this information in SQL. So my question is how can I gather the info from the "Property" in the textinput?

new TextInput
            {
                Prompt = new ActivityTemplate(question.Text),
                Property = "user.userProfile" + question.Id
            }

Upvotes: 0

Views: 268

Answers (2)

Kyle Delaney
Kyle Delaney

Reputation: 12264

You can see examples of how to access state properties all over this page:

new SendActivity("Hello, @{user.name}")

Upvotes: 1

Giang Nguyen
Giang Nguyen

Reputation: 151

Use CodeAction or HttpRequest to call your api to store the information

Use this to make HTTP requests to any endpoint.

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 */
}); 

Code Action

        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();
        }

Check out more detail here https://github.com/microsoft/BotBuilder-Samples/blob/master/experimental/adaptive-dialog/docs/recognizers-rules-steps-reference.md#HttpRequest

Upvotes: 3

Related Questions