Search code examples
c#botframeworkbotschatbot

Use FormDialog in sdk v4 of Microsoft Bot Framework


I have a chat bot that I built in sdk v3. I am updating the bot to sdkv4 and moving it to core2.0.

   protected async Task<DialogTurnResult> BeginChildDialogAsync(DialogContext dc, OnTurnProperty onTurnProperty)
    {
        var activity = dc.Context.Activity;
        var actionValue = onTurnProperty.Intent;
        switch (onTurnProperty.Intent)
        {

            case "quickquote":
                await dc.Context.SendActivityAsync("THIS IS QUICK QUOTE!");
                var survey = new FormDialog<QQForm>(new QQForm(), QQForm.BuildForm, FormOptions.PromptInStart, null);
                dc.Call(survey, AfterSurvey);

When I am calling the form that I built using formdialog. I get the error at dc.call(survey,AfterSurvey)

Severity Code Description Project File Line Suppression State Error CS1061 'DialogContext' does not contain a definition for 'Call' and no accessible extension method 'Call' accepting a first argument of type 'DialogContext' could be found (are you missing a using directive or an assembly reference?)

How do I change my formdialog in sdk v4?


Solution

  • Bot Framework v4 no longer has the concept of FormFlows. The way to archive this is using a combination of various techniques. I would recommend reading the following:

    After going through this documents, you should have enough to start adapting your code.

    Another fairly good example of collecting various inputs from users is provided in the official bot builder sample repo. Have a look here.

    I would go for a ComponentDialog containing a WaterfallDialog with a few validations. This way you can reuse everything as you're used to do it with form flows.