Pages Menu
TwitterRssFacebook

Posted by on Feb 8, 2020 in Bot Framework, Development

Bot Builder Community .NET Extensions v4.6.5 release, now with Adaptive Cards Prompt

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!”

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!!

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.