Reputation: 5520
I am currently working on Bot framework technology, in my current project I want to store the bot conversation data into azure SQL database.
I have developed one ReviewBot, In this I have to write the code for to give review/rating of any hotel by user.
Bot communicate with user is working fine but I want to store the user conversation data with my bot into azure SQL database using C# language.
Please tell me how to implement the above concept.
Regards, Pradeep
Upvotes: 2
Views: 3190
Reputation: 3075
I wrote a tutorial showing this: Implementing A SQL Server Database With The Microsoft Bot Framework
The key piece of code is:
// *************************
// 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();
Upvotes: 4