PromptDialog.Choice - 无效类型异常
PromptDialog.Choice - Invalid Type Exception
我在尝试使用 PromptDialog.Choice 时收到无效类型异常。
这是我的对话中的代码:
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;
}
OnResumeFromRescheduleChoice 方法正在触发,但结果显示失败,因为 ResumeAfter 委托需要字符串类型,但正在接收对象。这是对 PromptDialog 的错误使用吗?也不会提示用户选择。我正在使用 Bot.Builder 版本 3.5.5。
将 context.Done<object>(null);
调用移到 else
子句中。你不能在触发 Prompt
.
后调用 context.Done
我在尝试使用 PromptDialog.Choice 时收到无效类型异常。 这是我的对话中的代码:
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;
}
OnResumeFromRescheduleChoice 方法正在触发,但结果显示失败,因为 ResumeAfter 委托需要字符串类型,但正在接收对象。这是对 PromptDialog 的错误使用吗?也不会提示用户选择。我正在使用 Bot.Builder 版本 3.5.5。
将 context.Done<object>(null);
调用移到 else
子句中。你不能在触发 Prompt
.
context.Done