0
發送參數在我的對話我送一個用戶一個提示對話框:博特框架C#中PromptChoice.Choice
PromptOptions<string> options = new PromptOptions<string>($"some var" + var,
"invalid",
"Exceeded",
context.Activity.ChannelId.ToLower() == "skype" || context.Activity.ChannelId.ToLower() == "webchat" || context.Activity.ChannelId.ToLower() == "emulator" ?
new List<string>() { "yes","no","exit", } :
new List<string>() { "yes", "exit", },
3);
PromptDialog.Choice(context, this.OnOptionSelected, options);
,並在方法OnOptionSelected:
private async Task OnOptionSelected(IDialogContext context, IAwaitable<string> result)
{
string optionSelected = await result;
switch (optionSelected)
{
case "yes":
CallMethod(**Param1**, true);
break;
case "no":
CallMethod(**Param1**, false);
break;
case "exit":
context.Call(new ExitDialog(), this.ResumeAfterOptionDialog);
break;
}
}
如何傳遞參數1至OnOptionSelected方法,以便我可以使用它?
參數1和參數2取決於提示?或者你將如何獲得這些? –
參數1和參數2將不依賴於promptDialog。 – JoaoFilipeClementeMartins
好吧,因爲您無法更改OnOptionSelected方法的簽名。所以基本上你必須去BotState選項 –