Bot Builder Community .NET Extensions v4.6.5 release, now with Adaptive Cards Prompt
The Bot Builder Community repo is a collection of useful extensions to Bot Framework. The .Net Extensions repo in particular contains adapters, middleware, dialogs, helpers and other extensions which all help to make using Bot Framework on .NET easier.
The latest release of this is now out, and includes a new construct: the Adaptive Card Prompt. Getting data from users via adaptive cards is a really common use case, but laying on multiple questions, required input, and retries can quickly make code complicated and time-consuming. The Adaptive Card Prompt abstracts a lot of that pain, and also returns a nice JSON response for multiple answers which is then easy to consume:
// Load an adaptive card const cardJson = require('./adaptiveCard.json'); const card = CardFactory.adaptiveCard(cardJson); // Configure settings - All optional var promptSettings = new AdaptiveCardPromptSettings() { Card: card, InputFailMessage: 'Please fill out the adaptive card', RequiredInputIds: [ 'inputA', 'inputB', ], MissingRequiredInputsMessage: 'The following inputs are required', AttemptsBeforeCardRedsiplayed: 5, PromptId: 'myCustomId' } // Initialize the prompt var adaptiveCardPrompt = new AdaptiveCardPrompt('adaptiveCardPrompt', null, promptSettings); // Add the prompt to your dialogs dialogSet.add(adaptiveCardPrompt); // Call the prompt return await stepContext.prompt('adaptiveCardPrompt'); // Use the result const result = stepContext.result;
One of the really cool things about this new extension is that it directly came from a problem that a Support Engineer at Microsoft saw repeatedly, so he fixed! Michael Richardson raised an issue reporting that using Adaptive Cards to collect user input was harder than it should have been, and that he was going to work on a solution with Kyle Delaney, also from the Bot Framework Support Team. Fast forward to today, and we can all now benefit from their work and enjoy easier user input with Bot Framework. Thanks Michael and Kyle!
If you want to try this out for yourself, then you can grab the latest release from NuGet, or read more about it on the readme. You want to make sure you download (at least) version 4.6.5 to get the new stuff – as you can see from this screenshot, it’s really new!!