Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions core/samples/CompatBot/EchoBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivi
var mm = await CompatTeamsInfo.GetMemberAsync(turnContext, turnContext.Activity.From.Id);
string replyText = $"Echo {mm.Name} from BF Compat [{conversationData.MessageCount++}]: {turnContext.Activity.Text}";

// Targeted Messaging via BF compat layer: setting isTargeted on the BF ChannelAccount
// causes the compat layer to set CoreActivity.Recipient.IsTargeted, which appends
// ?isTargetedActivity=true to the URL making the message visible only to that user.
var act = MessageFactory.Text(replyText, replyText);
act.Recipient = new ChannelAccount();
act.Recipient.Properties.Add("isTargeted", true);
Expand All @@ -60,19 +63,15 @@ protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivi
cancellationToken
);


continuationToken = pagedMembersResult.ContinuationToken;
members.AddRange(pagedMembersResult.Members);
} while (continuationToken != null);

await turnContext.SendActivityAsync(JsonConvert.SerializeObject(members.Select(m => m.Name).ToList(), Formatting.Indented));
}




// await turnContext.SendActivityAsync(MessageFactory.Text($"Send a proactive message `/api/notify/{turnContext.Activity.Conversation.Id}`"), cancellationToken);

// Targeted Messaging via Core SDK (preferred): sends directly through ConversationClient
// to bypass the BF compat layer's ApplyConversationReference which would overwrite the Recipient.
var incomingCoreActivity = ((Activity)turnContext.Activity).FromCompatActivity();
CoreActivity tm = CoreActivity.CreateBuilder()
.WithConversation(new Conversation { Id = incomingCoreActivity.Conversation?.Id! })
Expand Down Expand Up @@ -101,6 +100,7 @@ await teamsBotApp.ConversationClient.AddReactionAsync(
cancellationToken);

await Task.Delay(500, cancellationToken);

await teamsBotApp.ConversationClient.AddReactionAsync(
turnContext.Activity.Conversation.Id,
res.Id,
Expand All @@ -116,12 +116,13 @@ await teamsBotApp.ConversationClient.DeleteReactionAsync(
turnContext.Activity.Conversation.Id,
res.Id,
"laugh",
//new Uri("https://pilot1.botapi.skype.com/amer/9a9b49fd-1dc5-4217-88b3-ecf855e91b0e/"),
//new Uri("https://pilot1.botapi.skype.com/amer/9a9b49fd-1dc5-4217-88b3-ecf855e91b0e/"),
incomingCoreActivity.ServiceUrl!,
AgenticIdentity.FromProperties(incomingCoreActivity.Recipient?.Properties),
null,
cancellationToken);

// Card submission triggers OnInvokeActivityAsync below.
Attachment attachment = new()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Expand Down
Loading