Use TM in SSO Flows#478
Open
rido-min wants to merge 10 commits into
Open
Conversation
Enhanced messages with user names for sign-in, sign-out, status, profile, and calendar commands. Added suggested action buttons for common commands in sign-in and help responses. Updated OAuthFlow recipient logic for conversation type and clarified ConversationType XML docs.
Refactor bot responses to use MessageActivity with Markdown formatting, explicitly setting Recipient and IsTargeted properties. This ensures correct message delivery and formatting in both 1:1 and group chat contexts. Update OAuthFlow to set recipient for OAuth cards based on conversation type.
Added the ExperimentalTeamsTargeted warning to the <NoWarn> property in SsoBot.csproj to prevent build warnings related to experimental Teams features. No other changes were made.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the SsoBot sample and related core OAuth/schema code to better support targeted (private) responses in group chat SSO scenarios, plus adds some UX improvements (suggested actions) and a small XML doc clarification.
Changes:
- Add targeted-recipient behavior in the OAuth sign-in flow when the conversation is a group chat.
- Improve SsoBot sample message formatting/personalization and add suggested-action buttons.
- Adjust XML documentation for
TeamsConversation.ConversationTypeand suppress experimental targeted-messaging warnings in the SsoBot sample project.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| core/src/Microsoft.Teams.Apps/Schema/TeamsConversation.cs | Updates XML doc reference for known conversation type values. |
| core/src/Microsoft.Teams.Apps/OAuth/OAuthFlow.cs | Sends OAuth card with recipient targeting in group chat contexts. |
| core/samples/SsoBot/SsoBot.csproj | Suppresses ExperimentalTeamsTargeted warnings for the sample. |
| core/samples/SsoBot/Program.cs | Adds suggested actions and attempts to target/personalize user-facing messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
181
to
185
| TeamsActivity oauthActivity = TeamsActivity.CreateBuilder() | ||
| .WithConversationReference(context.Activity) | ||
| .WithRecipient(context.Activity.From, false) | ||
| .WithRecipient(context.Activity.From, context.Activity?.Conversation?.ConversationType == ConversationType.GroupChat) | ||
| .WithAttachment(attachment) | ||
| .Build(); |
Comment on lines
+41
to
+50
| await context.SendActivityAsync(new MessageActivity("You're now signed in! Try `profile` or `calendar`.") | ||
| .WithSuggestedActions( | ||
| new SuggestedActions() | ||
| { | ||
| Actions = new List<SuggestedAction>() | ||
| { | ||
| new SuggestedAction() { Title = "Profile", Type = "imBack", Value = "profile" }, | ||
| new SuggestedAction() { Title = "Calendar", Type = "imBack", Value = "calendar" } | ||
| } | ||
| }), ct); |
Comment on lines
+62
to
+64
| signInFailureMessage.Recipient = context.Activity.From; | ||
| signInFailureMessage.Recipient?.IsTargeted = context.Activity?.Conversation?.ConversationType == ConversationType.GroupChat; // only set IsTargeted for 1:1 chats to avoid issues in group contexts | ||
| await context.SendActivityAsync(signInFailureMessage, ct); |
Comment on lines
+79
to
+81
| alreadySignedInMessage.Recipient = context.Activity.From; | ||
| alreadySignedInMessage.Recipient?.IsTargeted = context.Activity?.Conversation?.ConversationType == ConversationType.GroupChat; // only set IsTargeted for 1:1 chats to avoid issues in group contexts | ||
| await context.SendActivityAsync(alreadySignedInMessage, ct); |
Comment on lines
+102
to
+104
| msgResponse.Recipient = context.Activity.From; | ||
| msgResponse.Recipient?.IsTargeted = context.Activity?.Conversation?.ConversationType == ConversationType.GroupChat; // only set IsTargeted for 1:1 chats to avoid issues in group contexts | ||
| await context.SendActivityAsync(msgResponse, ct); |
Comment on lines
127
to
130
| catch (HttpRequestException ex) | ||
| { | ||
| await context.SendActivityAsync($"Graph call failed: {ex.Message}", ct); | ||
| await context.SendActivityAsync($"[{context.Activity.From?.Name}] Graph call failed: {ex.Message}", ct); | ||
| } |
Comment on lines
+140
to
+142
| signOutMessage.Recipient = context.Activity.From; | ||
| signOutMessage.Recipient?.IsTargeted = context.Activity?.Conversation?.ConversationType == ConversationType.GroupChat; // only set IsTargeted for 1:1 chats to avoid issues in group contexts | ||
| await context.SendActivityAsync(signOutMessage, ct); |
Comment on lines
+154
to
+156
| signInStatusMessage.Recipient = context.Activity.From; | ||
| signInStatusMessage.Recipient?.IsTargeted = context.Activity?.Conversation?.ConversationType == ConversationType.GroupChat; // only set IsTargeted for 1:1 chats to avoid issues in group contexts | ||
| await context.SendActivityAsync(signInStatusMessage, ct); |
Comment on lines
+177
to
+181
| Actions = new List<SuggestedAction>() | ||
| { | ||
| new SuggestedAction() { Title = "Login", Type = "imBack", Value = "login" }, | ||
| new SuggestedAction() { Title = "Logout", Type = "imBack", Value = "logout" }, | ||
| new SuggestedAction() { Title = "Status", Type = "imBack", Value = "status" }, |
Comment on lines
74
to
77
| /// <summary> | ||
| /// Conversation Type. See <see cref="ConversationType"/> for known values. | ||
| /// Conversation Type. See <see cref="Schema.ConversationType"/> for known values. | ||
| /// </summary> | ||
| [JsonPropertyName("conversationType")] public string? ConversationType { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances the SsoBot sample to provide a more personalized and user-friendly experience, especially in group chat scenarios. The main focus is on improving message formatting, adding suggested actions, and ensuring that responses are correctly targeted to individual users in group conversations.
Personalization and Targeting in Messages:
RecipientandIsTargetedproperties based on whether the chat is a group conversation, ensuring privacy and clarity in group contexts. [1] [2] [3] [4]User Experience Improvements:
OAuth Flow and Schema Adjustments:
ConversationTypeproperty inTeamsConversationto clarify its reference.