Idea: Bot.Builder.Community.Cards
See original GitHub issueI believe the only mention of Adaptive Cards in the Bot Builder SDK is in the Node SDK’s CardFactory
. I don’t think there’s any mention of Adaptive Cards in the .NET SDK.
As a Bot Framework support engineer, I see many recurring tasks that people want Adaptive Cards to perform in their bots. While there is already an Adaptive Cards NuGet package that provides some helpful models that bots can use, I think it would be even more helpful if there was an Adaptive Cards package that contained bot-specific functionality.
@mdrichardson has already created an Adaptive Card prompt that we have talked about making into a Bot Builder Community package. Since then, I’ve given some thought into whether we should have AdaptiveCardPrompt as its own package or include it in a package among other Adaptive Card utilities. Here is a short list of tools that I think would work well in an Adaptive Cards package:
- Translate cards - example: 1
- Disable cards - examples: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
- Dynamically add or remove elements to already-posted Adaptive Cards (only on channels that support message updates) - examples: 1, 2
- Automatically generate a card based on a data structure, the way FormFlow generates a dialog based on the information that needs to be gathered
Disabling Adaptive Cards is already built into Michael’s Adaptive Card prompt, but it’s possible that people might also want that kind of functionality without using a prompt. I listed my Adaptive Card prompt ideas in Michael’s DCR, but I’ll reiterate a short list of points about what Adaptive Card prompts are supposed to do here:
- Only accept input from specific cards that are bound to the prompt
- Allow both customized and automatic field validation
- Provide feedback about faulty input
I plan to work on this myself, so I am not making this post as a request for other people to work on it. I just want this to be a place to keep track of my ideas and get feedback from the community.
Update Jan 13, 2020:
I need to release v0.1 with only the features I’ve completed so far (or that I’m about to complete) in order to meet my Jan 31 deadline. This means the Adaptive Card Builder (idea 5) and the Action Prompt (my renamed version of the Adaptive Card prompt) will have to wait for another release. Here’s a checklist that might give a better idea of the scope of this library and my progress:
Card Translation
- Translate Adaptive Cards
- Translate Bot Framework cards
Card Management
- Apply ID’s to actions
- Disable cards by tracking ID’s in bot state
- Disable cards by updating their activities
- Dynamically add or remove card elements
- Adapt card actions between channels
- Adapt submit actions between channels (Teams vs non-Teams)
Adaptive Card Builder
- Generate an Adaptive Card based on a C# type
Action Prompt
- Return values retrieved from a Bot Framework card or an Adaptive Card
- Bind a specific card or cards to a prompt so input is not accepted from other cards
- Validate Adaptive Card fields and give feedback for invalid entries
Testing
- Translation tests
- Management tests
- Builder tests
- Prompt tests
Documentation
- Samples
- Readme file(s)
- Comments in code
Other languages
- Node
- Python
- Java
Track my progress
Update Jan 28, 2021:
The cards library has been merged into the develop and master branches
Update Feb 18, 2021:
The cards library is on NuGet: https://www.nuget.org/packages/Bot.Builder.Community.Cards/
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:11 (10 by maintainers)
Top GitHub Comments
Progress update: the project is mostly divided into the Translation folder and the Management folder, with the Management folder being many times more complicated. It handles card tracking by exposing functionality in three major classes:
ManagementExtensions
(for operations that don’t use bot state),CardManager
(which requires a state accessor), andCardManagerMiddleware
(which uses a card manager). I have written tests forManagementExtensions
andCardManager
. Once I’ve finished the tests forCardManagerMiddleware
then I’ll be able to create a card manager sample and finally demo this project.I think a big reason why this took a lot longer than I anticipated was because of the decision to include Bot Framework rich cards because I have to take many different situations into consideration. Adaptive Cards are pretty consistent with how they work, but rich cards behave a lot more differently on different channels than I realized and my library attempts to adapt their functionality. It wasn’t a bad decision, but if I was just doing Adaptive Cards then I may have gotten to this point at least a month sooner.
Once a usable version of the current cards library is released as a NuGet package, I will move on to the Adaptive Card builder portion and action prompt portion of the library. I have my hopes up that they won’t be quite as time-consuming.
I should mention that the scope of this idea has increased somewhat since I think that much of what people want to do with Adaptive Cards also applies to other rich cards (like disabling them), so I’m now just calling this the cards library. I’ve been working on this pretty heavily over the last month and I’ve been pushing my progress in the feature/cards branch.