Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions libraries/Microsoft.Bot.Builder/Teams/TeamsActivityHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ protected override async Task<InvokeResponse> OnInvokeActivityAsync(ITurnContext
case "composeExtension/queryLink":
return CreateInvokeResponse(await OnTeamsAppBasedLinkQueryAsync(turnContext, SafeCast<AppBasedLinkQuery>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false));

case "composeExtension/anonymousQueryLink":
return CreateInvokeResponse(await OnTeamsAnonymousAppBasedLinkQueryAsync(turnContext, SafeCast<AppBasedLinkQuery>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false));

case "composeExtension/query":
return CreateInvokeResponse(await OnTeamsMessagingExtensionQueryAsync(turnContext, SafeCast<MessagingExtensionQuery>(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false));

Expand Down Expand Up @@ -229,6 +232,19 @@ protected virtual Task<MessagingExtensionResponse> OnTeamsAppBasedLinkQueryAsync
throw new InvokeResponseException(HttpStatusCode.NotImplemented);
}

/// <summary>
/// Invoked when an anonymous app based link query activity is received from the connector.
/// </summary>
/// <param name="turnContext">A strongly-typed context object for this turn.</param>
/// <param name="query">The invoke request body type for app-based link query.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects
/// or threads to receive notice of cancellation.</param>
/// <returns>The Messaging Extension Response for the query.</returns>
protected virtual Task<MessagingExtensionResponse> OnTeamsAnonymousAppBasedLinkQueryAsync(ITurnContext<IInvokeActivity> turnContext, AppBasedLinkQuery query, CancellationToken cancellationToken)
{
throw new InvokeResponseException(HttpStatusCode.NotImplemented);
}

/// <summary>
/// Invoked when a messaging extension select item activity is received from the connector.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,39 @@ void CaptureSend(Activity[] arg)
Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status);
}

[Fact]
public async Task TestComposeExtensionAnonymousQueryLink()
{
// Arrange
var activity = new Activity
{
Type = ActivityTypes.Invoke,
Name = "composeExtension/anonymousQueryLink",
Value = JObject.FromObject(new AppBasedLinkQuery()),
};

Activity[] activitiesToSend = null;
void CaptureSend(Activity[] arg)
{
activitiesToSend = arg;
}

var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity);

// Act
var bot = new TestActivityHandler();
await ((IBot)bot).OnTurnAsync(turnContext);

// Assert
Assert.Equal(2, bot.Record.Count);
Assert.Equal("OnInvokeActivityAsync", bot.Record[0]);
Assert.Equal("OnTeamsAnonymousAppBasedLinkQueryAsync", bot.Record[1]);
Assert.NotNull(activitiesToSend);
Assert.Single(activitiesToSend);
Assert.IsType<InvokeResponse>(activitiesToSend[0].Value);
Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status);
}

[Fact]
public async Task TestComposeExtensionQuery()
{
Expand Down Expand Up @@ -1388,6 +1421,12 @@ protected override Task<MessagingExtensionResponse> OnTeamsAppBasedLinkQueryAsyn
return Task.FromResult(new MessagingExtensionResponse());
}

protected override Task<MessagingExtensionResponse> OnTeamsAnonymousAppBasedLinkQueryAsync(ITurnContext<IInvokeActivity> turnContext, AppBasedLinkQuery query, CancellationToken cancellationToken)
{
Record.Add(MethodBase.GetCurrentMethod().Name);
return Task.FromResult(new MessagingExtensionResponse());
}

protected override Task<InvokeResponse> OnTeamsCardActionInvokeAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken)
{
Record.Add(MethodBase.GetCurrentMethod().Name);
Expand Down