如何捕获聊天中发生的所有对话 - 使用Bot框架

时间:2016-10-17 05:54:53

标签: c# botframework

我正在尝试 Bot框架示例(三明治示例),我想检查是否有一种方法可以在完成聊天时捕获完整的对话。

示例:

我试图抓住双方在" OnCompletionAsyncDelegate"上的完整对话。事件。 是否可以选择捕获所有对话?

谢谢。

2 个答案:

答案 0 :(得分:0)

如果您正在使用LUIS,一种解决方案是创建您自己的Dialog类,该类扩展LuisDialog,覆盖MessageReceived以转录传入消息的文本,并让您的其他Dialogs扩展此新类而不是LuisDialog

如果您不使用LUIS,那么您的新课程可以在您自己的IDialog的MessageReceived实现中实现此逻辑。

转录逻辑需要在某处记录此文本,可能是表存储或dynamo db。

这有帮助吗?

答案 1 :(得分:0)

我有一个教程,介绍如何将对话捕获到数据库: Implementing A SQL Server Database With The Microsoft Bot Framework

捕获对话的关键代码是:

// *************************
// Log to Database
// *************************
// Instantiate the BotData dbContext
Models.BotDataEntities DB = new Models.BotDataEntities();
// Create a new UserLog object
Models.UserLog NewUserLog = new Models.UserLog();
// Set the properties on the UserLog object
NewUserLog.Channel = activity.ChannelId;
NewUserLog.UserID = activity.From.Id;
NewUserLog.UserName = activity.From.Name;
NewUserLog.created = DateTime.UtcNow;
NewUserLog.Message = activity.Text.Truncate(500);
// Add the UserLog object to UserLogs
DB.UserLogs.Add(NewUserLog);
// Save the changes to the database
DB.SaveChanges();
相关问题