【问题标题】:How to implement Entity Framework transcript store on Twitter Adapter如何在 Twitter 适配器上实现实体框架脚本存储
【发布时间】:2019-09-11 01:20:03
【问题描述】:
我正在使用 Entity Framework transcript store 将我的聊天记录保存在机器人框架 4 上,它在直线和模拟器上效果很好,但是当我添加 Twitter adapter 时,机器人会回答用户,但它不会存储任何内容频道,
我在使用方法的时候发现:
((TwitterAdapter)_adapter).ContinueConversationAsync(_appId, conversationReference, BotCallback, default(CancellationToken))
它存储传出的消息,但仍不保存传入的消息,
如何存储传入和传出的消息?
【问题讨论】:
-
只是想让你知道我们正在跟踪这个。在过去的几天里,我一直在这里和那里工作,但是在不重写整个适配器的情况下很难让它工作。希望你能得到答复here
-
标签:
c#
asp.net-core
botframework
【解决方案1】:
这对别人来说比什么都重要。
这个问题的核心是 Twitter Adapter 覆盖了其他的。由于 Entity Framework Transcript Store 使用 AdapterWithErrorHandler,因此 Twitter 适配器不允许调用它。
A PR was submitted 来解决这个问题,并使 Twitter Adapter 更符合其他 Bot Framework Adapters 的代码风格。一旦该 PR 被合并,这将起作用。
【解决方案2】:
推特适配器最后一次更新后,它现在可以工作了,请参考this answer,
基本上它说在 Startup.cs 文件中,在 ConfigureServices 方法中你必须有这个:
var store = new EntityFrameworkTranscriptStore(connection);
services.AddSingleton<ITranscriptStore>(store);
Configure 方法必须是这样的:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ITranscriptStore transcriptLogger)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseDefaultFiles();
app.UseStaticFiles();
//app.UseHttpsRedirection();
app.UseMvc();
app.UseTwitterAdapter();
app.ApplicationServices.GetRequiredService<TwitterAdapter>().Use(new TranscriptLoggerMiddleware(transcriptLogger));
}