I'm creating a chatbot in .Net C# using BotFramework. In one of my dialog when i start to fill a form flow i cannot exit from flowform till in the moment i will fill all the flow . Exist any possibility to exit and to leave form ?
This is my code :
LuisDialog.cs :
[LuisIntent("balance")]
public async Task balance(IDialogContext context, LuisResult result)
{
var balanca = new FormDialog<BalanceForm>(
new BalanceForm(),
BalanceForm.BuildForm,
FormOptions.PromptInStart,
result.Entities);
context.Call<BalanceForm>(balanca, BalanceCompleted);
BalanceForm.cs
namespace BasicMultiDialog
{
[Serializable]
public class BalanceForm
{
[Prompt("What is your contract number?")]
public string contract;
public static IForm<BalanceForm> BuildForm()
{
OnCompletionAsyncDelegate<BalanceForm> wrapUpRequest = async
(context, state) =>
{
string wrapUpMessage = "Dear " + house.Firstname + "," + "your balance is " + house.Balance;
await context.PostAsync(wrapUpMessage);
}
};
return new FormBuilder<BalanceForm>().Message
("We have to ask you some information")
.Field(nameof(contract), validate: async (state, response) =>
{
var result = new ValidateResult();
return result;
}
})
.OnCompletion(wrapUpRequest)
//.Confirm("Are you sure: Yes or No ")
.Build();
}
}
}
Actually it's quite easy to cancel a form. If you type "help" or "choices" you can see a list of builtin form commands, and one of these is "quit." There are many terms you can use to quit such as "finish" or "bye." If you want to define your own terms, you can can configure the form commands like this:
Keep in mind that when a form is canceled, a
FormCanceledException<T>
is thrown. If you don't want this to display a message like "Sorry, my bot code is having an issue," you can catch the exception like this: