How to store user conversation data with bot into azure SQL database using C# langugage?

后端 未结 1 964
南方客
南方客 2021-01-03 13:58

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 Rev

相关标签:
1条回答
  • 2021-01-03 14:58

    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();
    
    0 讨论(0)
提交回复
热议问题