0

I have been using Microsoft.Bot.Builder v3.x all this time to develop Bot. I have started using Microsoft.Bot.Builder v4.x to develop Bots, I made use of Microsoft.Bot.Builder.Classic to shift v3.0 bot solution to v4.0 bot solution.

I have come across one issue where I need to use StateClient object found within Microsoft.Bot.Connector v3.11.1 but I cannot find the same in Microsoft.Bot.Connector v4.0.1 which I cannot depricate since I have moved to Microsoft.Bot.Builder v4.x.

I need StateClient as I am moving authentication token(and few more data) from an MVC application to my Bot using StateClient and BotData.

StateClient _stateClient = result.GetStateClient();
BotState _botState = new BotState(_stateClient);
BotData _botData = await _botState.GetUserDataAsync(result.ChannelId, 
result.From.Id);
string _token = _botData.GetProperty<string>("AccessToken");
Tanmoy
  • 55
  • 1
  • 9
  • I seem to recall that StateClient has been deprecated. I can't find the announcement, but [this post](https://blogs.msdn.microsoft.com/premier_developer/2018/03/29/accessing-a-net-bots-state-via-dependency-injection/) refers to it, saying _"The .NET BotBuilder SDK has deprecated the StateClient class, leaving some to wonder how they should access their bot’s state."_ and links to [this article](https://blogs.msdn.microsoft.com/benwilli/2018/02/13/accessing-a-dotnet-bots-state-via-dependency-injection/) – stuartd Jul 10 '18 at 10:30
  • See also [this question](https://stackoverflow.com/questions/48327229/how-to-store-retrieve-bot-data-in-azure-table-storage-with-directline-channel) – stuartd Jul 10 '18 at 10:30
  • I did see these things, wondering there should have been some alternative – Tanmoy Jul 10 '18 at 10:36
  • I believe you have to implement your own storage, for example in Azure Table stoarge as per the answer to the linked question. – stuartd Jul 10 '18 at 10:37
  • exactly, hoping someone may have found some alternative – Tanmoy Jul 10 '18 at 10:45
  • That **is** the alternative. – stuartd Jul 10 '18 at 10:46

1 Answers1

1

Stop using StateClient. There is no alternative, it's deprecated (for a while now).

Alternatives are clearly listed in the documentation page called "Manage state data" here. It takes a few minutes to switch to Azure Cosmos DB or Table Storage, then you can use UserData, ConversationData or PrivateConversationData again.

Nicolas R
  • 13,812
  • 2
  • 28
  • 57