Dewiride.Azure.Bot.Framework.Cards.Helper 1.0.3

Prefix Reserved
dotnet add package Dewiride.Azure.Bot.Framework.Cards.Helper --version 1.0.3
                    
NuGet\Install-Package Dewiride.Azure.Bot.Framework.Cards.Helper -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dewiride.Azure.Bot.Framework.Cards.Helper" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dewiride.Azure.Bot.Framework.Cards.Helper" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Dewiride.Azure.Bot.Framework.Cards.Helper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dewiride.Azure.Bot.Framework.Cards.Helper --version 1.0.3
                    
#r "nuget: Dewiride.Azure.Bot.Framework.Cards.Helper, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dewiride.Azure.Bot.Framework.Cards.Helper@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dewiride.Azure.Bot.Framework.Cards.Helper&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Dewiride.Azure.Bot.Framework.Cards.Helper&version=1.0.3
                    
Install as a Cake Tool

Dewiride.Azure.Bot.Framework.Cards.Helper

NuGet Version NuGet Downloads

Overview

Dewiride.Azure.Bot.Framework.Cards.Helper is a .NET library that provides helper methods for creating and sending Adaptive Cards in Microsoft Bot Framework bots. This package simplifies the process of generating Adaptive Card attachments from JSON templates and sending them to users.

Installation

You can install the package via NuGet Package Manager:

dotnet add package Dewiride.Azure.Bot.Framework.Cards.Helper

Or via the NuGet Package Manager Console:

PM> Install-Package Dewiride.Azure.Bot.Framework.Cards.Helper

Usage

Creating an Adaptive Card from a Template

You can create an adaptive card attachment from a JSON template file using the CreateAdaptiveCard method:

using Dewiride.Azure.Bot.Framework.Cards.Helper;
using Microsoft.Bot.Schema;

string[] templatePath = { ".", "Cards", "YourCardTemplate.json" };
Attachment cardAttachment = CardsHelper.CreateAdaptiveCard(templatePath);

Creating an Adaptive Card with Data

You can merge data into an adaptive card template using the CreateAdaptiveCardWithData method:

using Dewiride.Azure.Bot.Framework.Cards.Helper;
using Microsoft.Bot.Schema;

string[] templatePath = { ".", "Cards", "YourCardTemplate.json" };
var data = new { Name = "John Doe", Age = 30 };
Attachment cardAttachment = CardsHelper.CreateAdaptiveCardWithData(templatePath, data);

Sending a Welcome Card

You can send a welcome card to the user using the SendWelcomeCardAsync method in a dialog step:

using Dewiride.Azure.Bot.Framework.Cards.Helper;
using Microsoft.Bot.Builder.Dialogs;
using System.Threading;
using System.Threading.Tasks;

public class MyBotDialog : ComponentDialog
{
    private readonly ICardsHelper _cardsHelper;

    public MyBotDialog(ICardsHelper cardsHelper)
    {
        _cardsHelper = cardsHelper;
    }

    private async Task<DialogTurnResult> WelcomeStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        var data = new { UserName = "John Doe" };
        await _cardsHelper.SendWelcomeCardAsync(data, stepContext, cancellationToken);
        return await stepContext.NextAsync(null, cancellationToken);
    }
}

Sending Suggested Actions

You can send suggested actions to the user using the SendSuggestedActionsAsync method:

public MyBotDialog(ICardsHelper cardsHelper)
{
    _cardsHelper = cardsHelper;
}

private async Task<DialogTurnResult> SuggestedActionsStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
    var cardActions = new List<CardAction>
    {
        new CardAction { Title = "Option 1", Type = ActionTypes.ImBack, Value = "Option 1" },
        new CardAction { Title = "Option 2", Type = ActionTypes.ImBack, Value = "Option 2" }
    };

    await _cardsHelper.SendSuggestedActionsAsync(stepContext, cancellationToken, "Please choose an option:", cardActions);
    return await stepContext.NextAsync(null, cancellationToken);
}

Dependency Injection

To use the CardsHelper with Dependency Injection (DI) in your bot project, register it in the Startup.cs or your DI setup:

using Dewiride.Azure.Bot.Framework.Cards.Helper;
using Microsoft.Extensions.DependencyInjection;

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<ICardsHelper, CardsHelper>();
    // Other service registrations
}

Company

  • Dewiride Technologies Private Limited

Repository

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 160 3/13/2025
1.0.2 106 1/23/2025
1.0.1 125 10/14/2024
1.0.0 141 6/28/2024

Added a new template for List Submit Action.