I have created a dispatcher, on getting a value of particular intent I called a child dialog as shown below:
if (topIntent == "NewRequest")
{
await dc.BeginDialogAsync(nameof(RequestForm));
// await dc.BeginDialogAsync("RequestForm",null,cancellationToken);
} else if(topIntent == "Mailbox")
{
await MaiboxAsync(dc, cancellationToken);
}
protected async Task MaiboxAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
{
await dc.BeginDialogAsync(nameof(MailboxAccessForm));
}
Whenever the top intent is new request or mailbox I get this error:
Error: Exception caught : DialogContext.BeginDialogAsync(): A dialog with an id of 'requestForm' wasn't found. The dialog must be included in the current or parent DialogSet
I have added the dialogs in DialogBot.cs file as shown below:
public class DialogBot<T> : ActivityHandler where T : Dialog
{
protected readonly Dialog Dialog;
// protected readonly BotState ConversationState;
protected readonly BotState UserState;
protected readonly ILogger Logger;
private IBotServices BotServices;
private IEnumerable<WaterfallStep> waterfallSteps;
private ConversationState ConversationState;
// private DialogSet _dialogs;
private DialogSet Dialogs { get; set; }
// private IConfiguration configuration;
public DialogBot(IBotServices botServices, ConversationState conversationState, UserState userState, T dialog, ILogger<DialogBot<T>> logger)
{
ConversationState = conversationState;
UserState = userState;
Dialog = dialog;
Logger = logger;
BotServices = botServices;
RegisterDialogs();
Dialogs = new DialogSet(conversationState.CreateProperty<DialogState>(nameof(DialogBot<T>)));
Dialogs.Add(new WaterfallDialog("MainDialog", new WaterfallStep[]
{
async (dc, cancellationToken) =>
{
// Start the ChoiceFlowDialog that was loaded earlier
// This will take the conversation through the
// 'waterfall' steps defined in the choiceFlow.json file
return await dc.BeginDialogAsync(nameof(RequestForm));
}
}));
}
private void RegisterDialogs()
{
Dialogs = new DialogSet(ConversationState.CreateProperty<DialogState> (nameof(DialogBot<T>)));
Dialogs.Add(new WaterfallDialog("CreateTeamForm", waterfallSteps));
Dialogs.Add(new WaterfallDialog("DistributionListForm", waterfallSteps));
Dialogs.Add(new WaterfallDialog("FeedbackForm", waterfallSteps));
Dialogs.Add(new WaterfallDialog("LicenseRequestForm", waterfallSteps));
Dialogs.Add(new WaterfallDialog("MailboxAccessForm", waterfallSteps));
Dialogs.Add(new WaterfallDialog("RequestForm", waterfallSteps));
Dialogs.Add(new WaterfallDialog("ServiceNowIncidentCreation", waterfallSteps));
Dialogs.Add(new WaterfallDialog("SharedMailboxForm", waterfallSteps));
}
}
In my startup.cs class I made these following changes:
services.AddTransient<IBot, DialogBot<MainDialog>>();
services.AddTransient<RequestFormForm>();
services.AddTransient<MailboxAccessForm>();
Where am I going wrong?
I have gone through some similar link on Stack Overflow but none of them resolved my issue.
Startup.cs
services.AddTransient<RequestFormForm>();
, this might be a spelling mistake. It's weird that it's saying idrequestForm
wasn't found because all the rest of yourRequestForm
are uppercase. Can you look in your code for the lowercase versionrequestForm
and replace it withRequestForm
? – craigbot