-
Notifications
You must be signed in to change notification settings - Fork 48
Add TeamsExtension sample #219
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
base: main
Are you sure you want to change the base?
Conversation
OnActivity(ActivityTypes.Message, OnMessageAsync); | ||
} | ||
|
||
private async Task<MessagingExtensionResult> OnSelectItem(ITurnContext turnContext, ITurnState turnState, object item, CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this handler seems to have breaking changes from BF-SDK: https://learn.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.teams.teamsactivityhandler.onteamsmessagingextensionselectitemasync?view=botbuilder-dotnet-stable
1, The previous API requires a MessageExtensionResponse instead of MessageExtensionResult
2. The returned item was a JObject and now it's an object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JObject
is gone. That is a NewtonSoft type. This will be an issue elsewhere in Teams and we'll need to document when we develop a migration story.
Not sure about the result/response. Would need to dig and/or talk to Teams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand JObject
is gone, I was suggesting using something better than object
, maybe a JsonElement
, or a Dictionary
. How users will know what to cast to get anything from the item
?
btw, Newtonsoft is still in our dependency graph, due to Adaptive Cards :(
|
||
return await Task.FromResult(new MessagingExtensionResult | ||
{ | ||
Type = "result", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add an Enum for this type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a number of places where, I believe we all agree, we need enum for things like this.
We will take this up with the teams extension team and see if we can get several of these areas improved with them.
@goldenwitch for visibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I love the enum suggestion.
This commit introduces a check for the `NuGetPackageName` parameter in the `OnQuery` method. If the parameter is undefined, the method now returns an empty `MessagingExtensionResult`. Additionally, the string interpolation for creating the `cardValue` has been updated to use triple quotes for improved readability and cleaner formatting of the JSON structure.
…ft/Agents-for-net into users/rido/teams-samples
It was my understanding we were not adding Teams samples to this repo. |
once we move the Teams extension, we will move the samples. In the meantime we need a tample to validate the Teams extension package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AllowedCallers was removed because when in use (at least) Audience validation was not working. It would either need to be fixed or removed.
AspNetExtensions has also been removed from the other samples
…to users/rido/teams-samples
…ft/Agents-for-net into users/rido/teams-samples
…to users/rido/teams-samples
…to users/rido/teams-samples
This pull request introduces a new Teams Agent sample, updates the solution file to include it, and makes improvements to the
AspNetExtensions
utility class. The most important changes include adding a new Teams Agent project with its implementation and configuration, updating the solution file to register the new project, and enhancing null safety and code readability in theAspNetExtensions
class.New Teams Agent Sample:
TeamsAgent
project with aMyAgent
implementation that handles Teams-specific features such as messaging extensions, message reactions, and conversation updates (src/samples/Teams/TeamsAgent/MyAgent.cs
).Program.cs
file to configure and run the Teams Agent application (src/samples/Teams/TeamsAgent/Program.cs
).TeamsAgent.csproj
) with dependencies on Teams-related libraries (src/samples/Teams/TeamsAgent/TeamsAgent.csproj
).appsettings.json
for configuration and a Teams manifest template for deployment (src/samples/Teams/TeamsAgent/appsettings.json
,src/samples/Teams/TeamsAgent/manifest/teams-manifest.TEMPLATE.jsonc
) [1] [2].Solution File Updates:
Microsoft.Agents.SDK.sln
to include the newTeamsAgent
project and its configurations (src/Microsoft.Agents.SDK.sln
) [1] [2] [3].Improvements to
AspNetExtensions
:!
) to prevent potential null reference exceptions inAddAgentAspNetAuthentication
(src/samples/Shared/AspNetExtensions.cs
) [1] [2] [3] [4] [5].AllowedCallersPolicy
class to use a primary constructor and simplified initialization of the_allowedCallers
field (src/samples/Shared/AspNetExtensions.cs
).src/samples/Shared/AspNetExtensions.cs
) [1] [2].