Skip to content

Cards sample using AgentApplication #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

tracyboehrer
Copy link
Member

@tracyboehrer tracyboehrer commented Mar 31, 2025

This, like the one in JS, is an adaptation of the one from BF, without Dialogs, and with the addition of AgentApplication.AdaptiveCards.

This also adds some helper methods in Channels to determine support for cards. Teams doesn't support several.

Note: This uses the new style of Program.cs that Matt used in the Auth samples.

@github-actions github-actions bot added the ML: Samples Tags changes to samples label Mar 31, 2025
@tracyboehrer tracyboehrer changed the title Beginnings of a AgentApplication Cards sample Cards samples using AgentApplication Mar 31, 2025
@github-actions github-actions bot added the ML: Core Tags changes to core libraries label Apr 9, 2025
@tracyboehrer tracyboehrer marked this pull request as ready for review April 9, 2025 20:50
@Copilot Copilot AI review requested due to automatic review settings April 9, 2025 20:50
@tracyboehrer tracyboehrer requested a review from a team as a code owner April 9, 2025 20:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 16 out of 22 changed files in this pull request and generated 2 comments.

Files not reviewed (6)
  • src/Microsoft.Agents.SDK.sln: Language not supported
  • src/samples/HandlingCards/HandlingCards.csproj: Language not supported
  • src/samples/HandlingCards/Resources/DynamicSearchCard.json: Language not supported
  • src/samples/HandlingCards/Resources/StaticSearchCard.json: Language not supported
  • src/samples/HandlingCards/appManifest/manifest.json: Language not supported
  • src/samples/HandlingCards/appsettings.json: Language not supported
Comments suppressed due to low confidence (1)

src/samples/HandlingCards/Cards.cs:18

  • The initialization of _cardCommands is incorrect. Replace the repeated assignment and square brackets with a proper collection initializer, e.g., 'new List { ... }'.
static IList<CardCommand> _cardCommands = _cardCommands = [

@tracyboehrer tracyboehrer changed the title Cards samples using AgentApplication Cards sample using AgentApplication Apr 9, 2025
{
await adapter.ProcessAsync(request, response, agent, cancellationToken);
})
.AllowAnonymous();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AllowAnonymoys should be added when IsDevelopment==true

.AllowAnonymous();

// Setup port and listening address.
app.Urls.Add("http://localhost:5000");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use defaults, that can be overriden with launchSettings?

why not 3978?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file produces Warnings in VS

Warning Property name is not allowed by the schema HandlingCards D:\Agents-for-net\src\samples\HandlingCards\Resources\DynamicSearchCard.json 37

Warning Value must conform to at least one of the associated schemas
| Value must be one of the following values: "compact", "expanded"
| or
| Value must match the regular expression ^([c|C][o|O][m|M][p|P][a|A][c|C][t|T])|([e|E][x|X][p|P][a|A][n|N][d|D][e|E][d|D])$ HandlingCards D:\Agents-for-net\src\samples\HandlingCards\Resources\DynamicSearchCard.json 48

@rido-min
Copy link
Member

When running the sample on Teams, I got two issues

  1. ReceiptCard is not rendered, instead I got: Go back to the main window to see this content.
  2. AnimationCard throws

Error: ReplyToActivity operation returned an invalid status code '(400) BadRequest'
HelpLink Url: https://aka.ms/AgentsSDK-Error07
Stack Trace: at Microsoft.Agents.Connector.RestClients.ConversationsRestClient.HandleExceptionResponse(HttpResponseMessage httpResponse, AgentErrorDefinition errorMessage, CancellationToken cancellationToken, String[] errors) in D:\Agents-for-net\src\libraries\Client\Microsoft.Agents.Connector\RestClients\ConversationsRestClient.cs:line 519
at Microsoft.Agents.Connector.RestClients.ConversationsRestClient.ReplyToActivityAsync(String conversationId, String activityId, IActivity body, CancellationToken cancellationToken) in D:\Agents-for-net\src\libraries\Client\Microsoft.Agents.Connector\RestClients\ConversationsRestClient.cs:line 263
at Microsoft.Agents.Connector.RestClients.ConversationsRestClient.ReplyToActivityAsync(IActivity activity, CancellationToken cancellationToken) in D:\Agents-for-net\src\libraries\Client\Microsoft.Agents.Connector\RestClients\ConversationsRestClient.cs:line 234
at Microsoft.Agents.Builder.ChannelServiceAdapterBase.SendActivitiesAsync(ITurnContext turnContext, IActivity[] activities, CancellationToken cancellationToken) in D:\Agents-for-net\src\libraries\Builder\Microsoft.Agents.Builder\ChannelServiceAdapterBase.cs:line 85
at Microsoft.Agents.Builder.TurnContext.<>c__DisplayClass37_0.<g__SendActivitiesThroughAdapter|1>d.MoveNext() in D:\Agents-for-net\src\libraries\Builder\Microsoft.Agents.Builder\TurnContext.cs:line 281

@rido-min
Copy link
Member

I was wondering this sample shows the value of:

public AgentApplicationBuilder WithAdaptiveCardOptions(AdaptiveCardsOptions adaptiveCardOptions)

However since it's not using the builder, I guess this has to be configured via appSettings, and seems the sample does not require it.

In which cases the Application requires WithAdaptiveCardOptions ?

@tracyboehrer
Copy link
Member Author

I was wondering this sample shows the value of:

public AgentApplicationBuilder WithAdaptiveCardOptions(AdaptiveCardsOptions adaptiveCardOptions)

However since it's not using the builder, I guess this has to be configured via appSettings, and seems the sample does not require it.

In which cases the Application requires WithAdaptiveCardOptions ?

I don't know. This portion of the sample came from the Teams AI SDK adaptiveCards.a.typeAheadBot. They didn't explicitly set that either. i.e., It just uses the default of "verb".

@rido-min
Copy link
Member

I noticed the AdaptiveCard is always configured in the ctor

Do we still need the "WithAdaptiveCards" method in the builder?

@tracyboehrer
Copy link
Member Author

Well I don't think we even need Builder. But that is another discussion. The entire thing is there for as much back-compat as we could leave.

It would appear AdaptiveCard.OnActionSubmit has some clues around that option.

@tracyboehrer
Copy link
Member Author

Also, this sample doesn't show OnExecute yet either.

@tracyboehrer
Copy link
Member Author

When running the sample on Teams, I got two issues

  1. ReceiptCard is not rendered, instead I got: Go back to the main window to see this content.
  2. AnimationCard throws

Error: ReplyToActivity operation returned an invalid status code '(400) BadRequest' HelpLink Url: https://aka.ms/AgentsSDK-Error07 Stack Trace: at Microsoft.Agents.Connector.RestClients.ConversationsRestClient.HandleExceptionResponse(HttpResponseMessage httpResponse, AgentErrorDefinition errorMessage, CancellationToken cancellationToken, String[] errors) in D:\Agents-for-net\src\libraries\Client\Microsoft.Agents.Connector\RestClients\ConversationsRestClient.cs:line 519 at Microsoft.Agents.Connector.RestClients.ConversationsRestClient.ReplyToActivityAsync(String conversationId, String activityId, IActivity body, CancellationToken cancellationToken) in D:\Agents-for-net\src\libraries\Client\Microsoft.Agents.Connector\RestClients\ConversationsRestClient.cs:line 263 at Microsoft.Agents.Connector.RestClients.ConversationsRestClient.ReplyToActivityAsync(IActivity activity, CancellationToken cancellationToken) in D:\Agents-for-net\src\libraries\Client\Microsoft.Agents.Connector\RestClients\ConversationsRestClient.cs:line 234 at Microsoft.Agents.Builder.ChannelServiceAdapterBase.SendActivitiesAsync(ITurnContext turnContext, IActivity[] activities, CancellationToken cancellationToken) in D:\Agents-for-net\src\libraries\Builder\Microsoft.Agents.Builder\ChannelServiceAdapterBase.cs:line 85 at Microsoft.Agents.Builder.TurnContext.<>c__DisplayClass37_0.<g__SendActivitiesThroughAdapter|1>d.MoveNext() in D:\Agents-for-net\src\libraries\Builder\Microsoft.Agents.Builder\TurnContext.cs:line 281

Does a ReceiptCard show in Teams using JS? Or BF SDK? I suspect not even if the Channels doc indicates it does.

This is an awkward sample. Several cards don't work in Teams, and why I added more "Channels.Supports*" methods.

@tracyboehrer
Copy link
Member Author

Will need to ping the Teams folks about ReceiptCard. Some other cards did that same Go back to the main window to see this content. response, but those were listed as not supported.

https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channels-reference?view=azure-bot-service-4.0#card-action-support-by-channel

Dropped support for AnimationCard on Teams since the doc indicates not supported.

Tracy Boehrer added 2 commits April 21, 2025 15:44
@tracyboehrer
Copy link
Member Author

@rido-min Update from branch. ReceiptCard will still be outstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HOLD ML: Core Tags changes to core libraries ML: Samples Tags changes to samples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants