如何使用 C# 语言将用户与 bot 的对话数据存储到 azure SQL 数据库中?
How to store user conversation data with bot into azure SQL database using C# langugage?
我目前正在研究 Bot 框架技术,在我当前的项目中我想将 bot 对话数据存储到 azure SQL 数据库中。
我开发了一个 ReviewBot,我必须在其中编写代码,让用户给 review/rating 任何一家酒店。
Bot 与用户的交流工作正常,但我想使用 C# 语言将用户与我的 bot 的对话数据存储到 Azure SQL 数据库中。
请告诉我如何实现上述概念。
此致,
普拉迪普
我写了一个教程来展示这个: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;
// Add the UserLog object to UserLogs
DB.UserLogs.Add(NewUserLog);
// Save the changes to the database
DB.SaveChanges();
我目前正在研究 Bot 框架技术,在我当前的项目中我想将 bot 对话数据存储到 azure SQL 数据库中。
我开发了一个 ReviewBot,我必须在其中编写代码,让用户给 review/rating 任何一家酒店。
Bot 与用户的交流工作正常,但我想使用 C# 语言将用户与我的 bot 的对话数据存储到 Azure SQL 数据库中。
请告诉我如何实现上述概念。
此致, 普拉迪普
我写了一个教程来展示这个: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;
// Add the UserLog object to UserLogs
DB.UserLogs.Add(NewUserLog);
// Save the changes to the database
DB.SaveChanges();