我目前正在研究 Bot 框架技术,在我当前的项目中,我想将 bot 对话数据存储到 azure SQL 数据库中。
我开发了一个 ReviewBot,在其中我必须编写代码来按用户对任何酒店进行评论/评级。
机器人与用户的通信工作正常,但我想使用 C# 语言将用户与机器人的对话数据存储到 azure SQL 数据库中。
请告诉我如何实现上述概念。
问候,
普拉迪普
我写了一个教程来展示这一点:使用 Microsoft Bot 框架实现 SQL Server 数据库 http://aihelpwebsite.com/Blog/EntryId/13/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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)