Since we are forced to drop the client state and go to the user repository, in my case it is an Azure table repository . Using my storageexplorer, I see that it already saved the conversation data on my azure. How can I update my ff code to get chat history? I used to use the IActivityLogger class to record a conversation, but now I'm not sure how to update it.
Global Asax before:
protected void Application_Start() { var builder = new ContainerBuilder(); builder.RegisterType<Logger>().AsImplementedInterfaces().InstancePerDependency(); builder.Update(Conversation.Container); GlobalConfiguration.Configure(WebApiConfig.Register); }
Global Asax after:
protected void Application_Start() { Conversation.UpdateContainer(builder => { builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly())); var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString); builder.Register(c => store) .Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore) .AsSelf() .SingleInstance(); }); GlobalConfiguration.Configure(WebApiConfig.Register); }
Logger Class:
public class Logger:IActivityLogger { public static ConcurrentDictionary<string, List<IActivity>> Messages = new ConcurrentDictionary<string, List<IActivity>>(); public Task LogAsync(IActivity activity) { try { var list = new List<IActivity>() { activity }; Messages.AddOrUpdate(activity.Conversation.Id, list, (k, v) => { v.Add(activity); return v; }); return Task.FromResult(false); } catch (System.Exception) { throw; } } }
Here's how I use it (how can I update the stateclient part and use my storage on Azure ?:
var reply = activity.CreateReply(); var storedActivities = new List<IActivity>(); var found = Logger.Messages.TryGetValue(activity.Conversation.Id, out storedActivities); if (storedActivities != null) { foreach (var storedActivity in storedActivities) { reply.Text += $" <br /> <b>{storedActivity.From.Name}:</b> {storedActivity.AsMessageActivity().Text}"; }
They gave a new Tablelogger class. Unfortunately, I do not know how to consume it. TableLogger.cs
c # azure-storage azure-table-storage chatbot botframework
anonymous1110
source share