Reputation: 107
I am getting an invalid Type exception when trying to utilize PromptDialog.Choice. Here is my code from on of my dialogs:
public async Task StartAsync(IDialogContext context) {
await context.PostAsync(ConversationHelper.CreateReschedulePromptMessage());
context.Wait(MessageReceivedAsync);
}
public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) {
var message = await result;
var Options = new[] { "Location", "Date and Time", "Both" };
if (message.Text.ToUpper().CompareTo("PICKUP") == 0) {
_rescheduleType = "pickup";
string prompt = string.Format("Is the {0} location incorrect, is the date and time incorrect, or both?", _rescheduleType);
PromptDialog.Choice(context, OnResumeFromRescheduleChoice, Options, prompt, promptStyle: PromptStyle.Auto, descriptions: Options);
}
else if (message.Text.ToUpper().CompareTo("DROP") == 0) {
_rescheduleType = "drop-off";
string prompt = string.Format("Is the {0} location incorrect, is the date and time incorrect, or both?", _rescheduleType);
PromptDialog.Choice(context, OnResumeFromRescheduleChoice, Options, prompt, promptStyle: PromptStyle.Auto, descriptions: Options);
}
else {
await context.PostAsync(ConversationHelper.CreateGenericRescheduleMessage(SUPPORTNUMBER));
}
context.Done<object>(null);
}
private async Task OnResumeFromRescheduleChoice(IDialogContext context, IAwaitable<string> result) {
var choice = await result;
}
The OnResumeFromRescheduleChoice method is firing, but the result shows failed because the ResumeAfter delegate is expecting type string, but is receiving object. Is this incorrect usage of the PromptDialog? Also the user is not being prompted the choices. I am using Bot.Builder version 3.5.5.
Upvotes: 1
Views: 262
Reputation: 14787
Move the context.Done<object>(null);
call inside the else
clause. You cannot call to context.Done
after firing a Prompt
.
Upvotes: 2