我创建了一个LUIS根对话框,根据意图创建对话框。我找到了一个示例代码来执行Proactive Bot Messages,但它似乎不适用于框架的v3.9.0。
我添加了一个Conversation Starter类:
public class ConversationStarter
{
public static string ResumptionCookie;
SurveyDialog, then wait until that's done
public static async Task Resume()
{
var message = Microsoft.Bot.Builder.Dialogs.ResumptionCookie.GZipDeserialize(ResumptionCookie).GetMessage();
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
var botData = scope.Resolve<IBotData>();
await botData.LoadAsync(CancellationToken.None);
var stack = scope.Resolve<IDialogStack>();
var dialog = new CreateTradeAfterInterrupt();
stack.Call(dialog.Void<object, IMessageActivity>(), null);
await stack.Poll(CancellationToken.None);
await botData.FlushAsync(CancellationToken.None);
}
}
}
删除了“stack.Poll”方法。这个新版本的框架是否有相应的内容?如果我对这一行进行评论,则根本不会发生中断。
我在MessageController级别设置了Resumption Cookie:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
ConversationStarter.ResumptionCookie = new ResumptionCookie(activity).GZipSerialize();
await Conversation.SendAsync(activity, MakeLuisDialog);
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
我有另一个控制器用于将事件发布到并执行:
await ConversationStarter.Resume();
CreateTrade对话框是一个简单的对话框,它调用PromptDialog.Choice并为用户提供买卖股票等的选项。
知道为什么这不起作用吗?