title: How to store UserState and ConversationState in Azure Cosmos DB (BotFramework)?
body: <p>I'm doing a bot with de Microsoft Bot Framework version V4. The documentation is really awful, and I'm having problems with Cosmos DB (Azure) when I try to store de UserSate and the ConversationState.</p>
  
  <p>I tried every result in Google but nothing has worked yet. Plus, there no much information about the framework really.</p>
  
  <p>Bellow is the code of the file Startup.cs.</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddBot&lt;SeguritoBot&gt;(options =&gt;
     {
         var secretKey = Configuration.GetSection("botFileSecret")?.Value;
         var botFilePath = Configuration.GetSection("botFilePath")?.Value;
  
      // Loads .bot configuration file and adds a singleton that your Bot can access through dependency injection.
      var botConfig = BotConfiguration.Load(botFilePath ?? @".\Segurito.bot", secretKey);
     services.AddSingleton(sp =&gt; botConfig ?? throw new InvalidOperationException($"The .bot config file could not be loaded. ({botConfig})"));
  
      // Retrieve current endpoint.
      var environment = _isProduction ? "production" : "development";
     var service = botConfig.Services.FirstOrDefault(s =&gt; s.Type == "endpoint" &amp;&amp; s.Name == environment);
     if (!(service is EndpointService endpointService))
     {
         throw new InvalidOperationException($"The .bot file does not contain an endpoint with name '{environment}'.");
     }
  
     options.CredentialProvider = new SimpleCredentialProvider(endpointService.AppId, endpointService.AppPassword);
  
      // Creates a logger for the application to use.
      ILogger logger = _loggerFactory.CreateLogger&lt;SeguritoBot&gt;();
  
      // Catches any errors that occur during a conversation turn and logs them.
      options.OnTurnError = async (context, exception) =&gt;
     {
         logger.LogError($"Exception caught : {exception}");
         await context.SendActivityAsync("Sorry, it looks like something went wrong.");
     };
  
     var optionsConversation = new CosmosDbStorageOptions()
     {
         CosmosDBEndpoint = new Uri("--secret--"),
         AuthKey = "--secret--",
         DatabaseId = "--secret--",
         CollectionId = "--secret--"
     };
  
     var optionsUser = new CosmosDbStorageOptions()
     {
         CosmosDBEndpoint = new Uri("--secret--"),
         AuthKey = "--secret--",
         DatabaseId = "--secret--",
         CollectionId = "--secret--"
     };
  
     IStorage dataStoreConversationState = new CosmosDbStorage(optionsConversation);
     IStorage dataStoreUserState = new CosmosDbStorage(optionsUser);
  
     options.Middleware.Add(new ConversationState&lt;ConversationState&gt;(dataStoreConversationState));
     options.Middleware.Add(new UserState&lt;UserState&gt;(dataStoreUserState));
     });
  }
  </code></pre>
  
  <p>The last to lines are giving the error:</p>
  
  <pre><code>The non-generic type 'ConversationState' cannot be used with type arguments
  The non-generic type 'ConversationState' cannot be used with type arguments 
  </code></pre>