如何使用C#语言将具有Bot的用户对话数据存储到Azure SQL数据库中? [英] How to store user conversation data with bot into azure SQL database using C# langugage?

查看:69
本文介绍了如何使用C#语言将具有Bot的用户对话数据存储到Azure SQL数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究Bot框架技术,在我当前的项目中,我想将机器人对话数据存储到Azure SQL数据库中.

I am currently working on Bot framework technology, in my current project I want to store the bot conversation data into azure SQL database.

我开发了一个ReviewBot,在此我必须编写代码以根据用户对任何酒店进行评论/评分.

I have developed one ReviewBot, In this I have to write the code for to give review/rating of any hotel by user.

与用户进行的良好沟通正常,但我想使用C#语言将与我的机器人的用户对话数据存储到Azure SQL数据库中.

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.

关于, 普拉迪普(Pradeep)

Regards, Pradeep

推荐答案

我写了一个教程,显示了这一点:

I wrote a tutorial showing this: 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();

这篇关于如何使用C#语言将具有Bot的用户对话数据存储到Azure SQL数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆