Search code examples
c#.netbotframework

Microsoft Bot Framework System.ArgumentException: 'EncryptedText is not properly formatted'


I'm working with the latest bot framework update. I have two questions.

  1. The first thing I'm curious about is upon initial setup I've inputted the botFilePath and botFileSecret into the appsettings.json as requested by the README.md. Once I try to run this locally, it seems to be unable to read from the appsettings.json. I've looked into the Configuration class variable but can't figure out why it's not able to get the values from the keys I've put in. This is a snippet of the code - I've pretty much copied it from https://github.com/Microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/05.multi-turn-prompt/Startup.cs

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddBot<MultiTurnPromptsBot>(options =>
        {
            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, secretKey);
    

and it fails at BotConfiguration.Load(...) because botFilePath is null (NullException error).

  1. If I try and hardcode in values for secretKey and botFilePath from my appsettings.json file right into the bot code, then I get a new error:

System.ArgumentException: 'EncryptedText is not properly formatted' failing in the same place. I've got my secret code from the Azure portal under the application settings... I'm unable to find any information on the ArgumentException error. Anyone have any advice?


Solution

  • The second problem is solved by setting the padlock of the .bot file to the empty string.