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
<PackageReference Include="Dewiride.Azure.Bot.Framework.Cards.Helper" Version="1.0.3" />
<PackageVersion Include="Dewiride.Azure.Bot.Framework.Cards.Helper" Version="1.0.3" />
<PackageReference Include="Dewiride.Azure.Bot.Framework.Cards.Helper" />
paket add Dewiride.Azure.Bot.Framework.Cards.Helper --version 1.0.3
#r "nuget: Dewiride.Azure.Bot.Framework.Cards.Helper, 1.0.3"
#:package Dewiride.Azure.Bot.Framework.Cards.Helper@1.0.3
#addin nuget:?package=Dewiride.Azure.Bot.Framework.Cards.Helper&version=1.0.3
#tool nuget:?package=Dewiride.Azure.Bot.Framework.Cards.Helper&version=1.0.3
Dewiride.Azure.Bot.Framework.Cards.Helper
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 | Versions 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. |
-
net8.0
- AdaptiveCards.Templating (>= 2.0.5)
- Microsoft.Bot.Builder.Dialogs (>= 4.23.0)
- Microsoft.Bot.Schema (>= 4.23.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added a new template for List Submit Action.