Skip to content

[Doc Improvement][Config search command][2366221] #5754

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
2a61c72
Update respond-to-search.md
v-npaladugu Apr 20, 2022
74e8d7b
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Apr 28, 2022
f81cc3d
Update respond-to-search.md
v-npaladugu Apr 28, 2022
44c092a
Update respond-to-search.md
v-npaladugu Apr 28, 2022
030d441
Update respond-to-search.md
v-npaladugu Apr 28, 2022
a31031c
Update respond-to-search.md
v-npaladugu Apr 28, 2022
0d94cdf
Update respond-to-search.md
Wajeed-msft Apr 29, 2022
4d5ae97
Update respond-to-search.md
Wajeed-msft Apr 29, 2022
602c576
Update respond-to-search.md
v-npaladugu May 12, 2022
9490d0a
Merge branch 'main' into Doc-issue-config-command
v-npaladugu May 13, 2022
b517619
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Nov 30, 2022
c43ff18
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Aug 30, 2023
f32dd99
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Jan 22, 2024
bb315ca
Updates
v-npaladugu Jan 22, 2024
c9263ee
Updates
v-npaladugu Jan 27, 2024
0179387
Update respond-to-search.md
v-npaladugu Jan 29, 2024
6891a92
Merge branch 'main' into Doc-issue-config-command
v-ypalikila Jan 30, 2024
808601e
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Jan 30, 2024
12a473e
Merge branch 'Doc-issue-config-command' of https://github.com/Microso…
v-npaladugu Jan 30, 2024
8c3b3c6
Update respond-to-search.md
v-npaladugu Feb 5, 2024
5dd1161
Update respond-to-search.md
v-npaladugu Feb 5, 2024
08a3ba4
Update respond-to-search.md
v-npaladugu Feb 5, 2024
578c512
Update respond-to-search.md
v-npaladugu Feb 5, 2024
d893b37
Update respond-to-search.png
v-npaladugu Feb 5, 2024
36d60f0
Update respond-to-search.png
v-npaladugu Feb 7, 2024
d9e8ef7
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Feb 29, 2024
5b3e70f
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Apr 24, 2024
ecd2a2a
Update respond-to-task-module-submit.md
v-npaladugu Apr 24, 2024
127886b
Update respond-to-task-module-submit.md
v-npaladugu Apr 24, 2024
ff206f8
Update respond-to-task-module-submit.md
v-npaladugu Apr 24, 2024
694909f
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Jun 11, 2024
1225b0a
Update respond-to-search.md
v-npaladugu Jun 11, 2024
42cb1f2
Update respond-to-search.md
v-npaladugu Jun 11, 2024
a6fe253
Merge branch 'main' into Doc-issue-config-command
v-npaladugu Sep 17, 2024
9b1cdf1
Update respond-to-search.md
v-npaladugu Sep 17, 2024
1d6306f
Merge branch 'main' into Doc-issue-config-command
v-preethah Dec 7, 2024
6fc50ed
review fixes
v-preethah Dec 7, 2024
ed6a8eb
Merge branch 'main' into Doc-issue-config-command
v-preethah Jan 8, 2025
9c09e4f
review fixes
v-preethah Jan 8, 2025
2d4ad9d
Merge branch 'main' into Doc-issue-config-command
v-preethah Jan 20, 2025
1f9495e
self check
v-preethah Jan 20, 2025
84831e7
date fixes
v-preethah Jan 20, 2025
b871593
Merge branch 'main' into Doc-issue-config-command
v-preethah Feb 5, 2025
27c22de
Merge branch 'main' into Doc-issue-config-command
v-preethah Feb 6, 2025
ddf256f
review update
v-preethah Feb 6, 2025
280444e
review comment update
v-preethah Feb 7, 2025
e375522
Merge branch 'main' into Doc-issue-config-command
v-preethah Feb 7, 2025
217bae7
Merge branch 'main' into Doc-issue-config-command
v-preethah Feb 11, 2025
fd4e6f9
review update
v-preethah Feb 11, 2025
34c2d44
review fixes
v-preethah Feb 11, 2025
e147c44
Merge branch 'main' into Doc-issue-config-command
v-preethah Mar 3, 2025
bfb473a
self check fixes
v-preethah Mar 3, 2025
350bfdf
Merge branch 'main' into Doc-issue-config-command
v-preethah Mar 24, 2025
f44d3ad
review fixes
v-preethah Mar 24, 2025
de70097
review content fix
v-preethah Mar 26, 2025
1bdb96c
Merge branch 'main' into Doc-issue-config-command
v-preethah Mar 28, 2025
0bb7d10
Merge branch 'main' into Doc-issue-config-command
v-preethah Apr 2, 2025
d9eb1ac
review comment updates
v-preethah Apr 2, 2025
d394138
self check fix
v-preethah Apr 2, 2025
3036756
Merge branch 'main' into Doc-issue-config-command
v-preethah Apr 9, 2025
419d38c
review updates
v-preethah Apr 9, 2025
1ad6ca3
Merge branch 'main' into Doc-issue-config-command
v-preethah Apr 14, 2025
7869389
review fixes
v-preethah Apr 14, 2025
3e222e3
Merge branch 'main' into Doc-issue-config-command
v-preethah Apr 25, 2025
e04ec20
review fix
v-preethah Apr 25, 2025
d9ac02a
Merge branch 'main' into Doc-issue-config-command
v-preethah May 2, 2025
ad7dadf
review fix
v-preethah May 2, 2025
83ac1dc
Merge branch 'main' into Doc-issue-config-command
v-preethah May 27, 2025
8016a3c
review fixes
v-preethah May 28, 2025
6f103a7
image resize fix
v-preethah May 28, 2025
6dce7f9
Merge branch 'main' into Doc-issue-config-command
v-preethah Jun 3, 2025
aab728d
image fix
v-preethah Jun 3, 2025
52bd599
warning fix
v-preethah Jun 3, 2025
edeaff4
Merge branch 'main' into Doc-issue-config-command
v-bijinc Jun 17, 2025
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
Binary file modified msteams-platform/assets/images/configuration-response-me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ ms.localizationpriority: medium

[!include[v4-to-v3-SDK-pointer](~/includes/v4-to-v3-pointer-me.md)]

After the user submits the search command, your web service receives a `composeExtension/query` invoke message that contains a `value` object with the search parameters. The invoke is triggered with the following conditions:
After the user submits the search command, your web service receives a `composeExtension/query` invoke message that contains a `value` object with the search parameters. The invoke is triggered by the following conditions:

* As characters are entered into the search box.
* `initialRun` is set to true in your [app manifest](../../../resources/schema/manifest-schema.md#composeextensions) and you receive the invoke message as soon as the search command is invoked. For more information, see [default query](#default-query).
* `initialRun` is set to true in your [app manifest](../../../resources/schema/manifest-schema.md#composeextensions). For more information, see [default query](#default-query).

This document guides you on how to respond to user requests in the form of cards and previews, and the conditions under which Microsoft Teams issues a default query.
This document guides you on how to respond to user requests in the form of cards and previews and the conditions under which Microsoft Teams issues a default query.

The request parameters are found in the `value` object in the request, which includes the following properties:

| Property name | Purpose |
|---|---|
| `commandId` | The name of the command invoked by the user, matching one of the commands declared in the app manifest. |
| `parameters` | Array of parameters. Each parameter object contains the parameter name, along with the parameter value provided by the user. |
| `parameters` | Array of parameters. Each parameter object contains the parameter name along with the parameter value provided by the user. |
| `queryOptions` | Pagination parameters: <br>`skip`: Skip count for this query <br>`count`: Number of elements to return. |

# [C#/.NET](#tab/dotnet1)
Expand Down Expand Up @@ -105,8 +105,8 @@ The following code snippet shows the `config` response that appears when the use
"actions": [
{
"type": "openUrl",
"title": "Open URL",
"value": "https://<your-subdomain>"
"title": "Open url",
"value": "https://<your-tunnel-url>/searchSettings.html?settings="
}
]
},
Expand Down Expand Up @@ -149,6 +149,31 @@ To complete the message extension configuration flow:

4. Once `notifySuccess()` is executed, the configuration window automatically closes and the message extension is set up successfully.

### `auth` response type

If your service requires user authentication, the users must # before they use the message extension. For more information, see [authentication](~/messaging-extensions/how-to/add-authentication.md#authentication).

### `message` response type

A `message` response is used when your extension needs to display a plain text message. The `message` response type doesn't support formatting.

The following code snippet is an example of a `message` response returned by the app:

```csharp

return new MessagingExtensionResponse
{
ComposeExtension = new MessagingExtensionResult
{
Type = "message",
Text = "Here is the message you want to show!"
}
};

```

:::image type="content" source="../../../assets/images/messaging-extension/message-response-type.png" alt-text="Screenshot shows the message response type.":::

### `result` response type

The result list is displayed in the Microsoft Teams UI with a preview of each item. The preview is generated in one of the two ways:
Expand All @@ -166,11 +191,9 @@ Teams supports the following card types:
* [Connector card for Microsoft 365 Groups](~/task-modules-and-cards/cards/cards-reference.md#connector-card-for-microsoft-365-groups)
* [Adaptive Card](~/task-modules-and-cards/cards/cards-reference.md#adaptive-card)

**Hero or Thumbnail card**
:::image type="content" source="../../../assets/images/messaging-extension/result-response-search-cmd.png" alt-text="Screenshot shows the result response type.":::

For the hero or thumbnail card, except for the invoke action, other actions such as button and tap aren't supported in the preview card. For hero and thumbnail cards, a preview is generated by default and you don't need to specify a `preview` property. To know about cards and learn how to use the thumbnail and hero card types, see [what are cards](~/task-modules-and-cards/what-are-cards.md) and [add cards and card actions](~/task-modules-and-cards/cards/cards-actions.md).

**Adaptive Card or connector card**
For the hero or thumbnail card, except for the invoke action, other actions such as button and tap aren't supported in the preview card. For hero and thumbnail cards, you don't need to specify a preview property, a preview is generated by default. To know about cards and learn how to use the thumbnail and hero card types, see [what are cards](~/task-modules-and-cards/what-are-cards.md) and [add cards and card actions](~/task-modules-and-cards/cards/cards-actions.md).

To send an Adaptive Card or connector card for Microsoft 365 Groups, you must include a preview. The `preview` property must be a hero or thumbnail card and the respective card is generated as preview. If a `preview` property isn't specified in the `attachment` object, a preview isn't generated. For more information, see [using connector cards for Microsoft 365 Groups](~/task-modules-and-cards/cards/cards-reference.md#connector-card-for-microsoft-365-groups).

Expand Down Expand Up @@ -449,6 +472,8 @@ async def on_teams_messaging_extension_query(self, context, query):

### Enable and handle tap actions

When a user selects a result from the message extension search query, the preview card displays the description and the Tap actions that were defined. The Tap action must have the required value property assigned that displays as a Tap button in the card sent.

# [.NET](#tab/csharp3)

* [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/msgext-search/csharp/Bots/TeamsMessagingExtensionsSearchBot.cs#L80)
Expand Down Expand Up @@ -548,7 +573,7 @@ async def on_teams_messaging_extension_select_item(

If you set `initialRun` to `true` in the manifest, Microsoft Teams issues a **default** query when the user first opens the message extension. Your service can respond to this query with a set of prepopulated results. This is useful when your search command requires authentication or configuration, displaying recently viewed items, favorites, or any other information that isn't dependent on user input.

The default query has the same structure as any regular user query, with the `name` field set to `initialRun` and `value` set to `true` as shown in the following object:
The default query has the same structure as any regular user query, except it has a parameter named `initialRun` that's set to a string value of `true`, as shown in the following object:

```json
{
Expand All @@ -573,7 +598,7 @@ The default query has the same structure as any regular user query, with the `na

## Code sample

| Sample name | Description | .NET | Node.js | Manifest|
| Sample name | Description | .NET | Node.js | Manifest |
|:---------------------|:--------------|:---------|:--------|:--------|
| Teams message extension search | This sample demonstrates how to create a message extension in Teams that allows users searches for NuGet packages and retrieve the results as a card. |[View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search/csharp)|[View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search/nodejs)|[View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search/csharp/demo-manifest/msgext-search.zip)
|Teams message extension auth and config | This sample demonstrates how to implement authentication in a message extension for Teams, enabling secure access and user-specific interactions. |[View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search-auth-config/csharp)|[View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search-sso-config/nodejs)|[View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search-auth-config/csharp/demo-manifest/msgext-search-auth-config.zip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,69 @@ The `onQuerySettingsUrl` and `onSettingsUpdate` events work together to enable t

:::image type="content" source="../../assets/images/compose-extensions/compose-extension-settings-menu-item.png" alt-text="Screenshot shows the locations of Settings menu item.":::

Your handler for `onQuerySettingsUrl` returns the URL for the configuration page; after the configuration page closes, your handler for `onSettingsUpdate` accepts and saves the returned state. This is the one case in which `onQuery` *doesn't* receive the response from the configuration page.
The [`onQuerySettingsUrl`](/dotnet/api/microsoft.teams.ai.messageextensions-1.onquery) handler returns the URL for the configuration page when a user clicks on the settings button. After the configuration page is closed, the `onSettingsUpdate` method is called to accept and save the returned state. The `onQuery` handler then retrieves the updated settings and uses them to update the behavior of the message extension. This is the one case in which `onQuery` *doesn't* receive the response from the configuration page.

If a message extension uses a configuration page, the `onQuery` handler should first verify for any stored configuration data. If the message extension isn't configured, a `config` response must be returned, which includes a link to your configuration.

The following image shows the `config` command workflow:

:::image type="content" source="~/assets/images/messaging-extension/respond-to-search.png" alt-text="Screenshot shows the config command workflow and how it works.":::

The following code handles a user request for the configuration page of a message extension. It fetches the user's existing configuration settings, escapes them, and builds a response. This response includes the configuration page's URL with the escaped settings added as a query parameter.

```csharp

protected override async Task<MessagingExtensionResponse> OnTeamsMessagingExtensionConfigurationQuerySettingUrlAsync(ITurnContext<IInvokeActivity> turnContext, MessagingExtensionQuery query, CancellationToken cancellationToken)
{
// The user has requested the Messaging Extension Configuration page.
var escapedSettings = string.Empty;
var userConfigSettings = await _userConfigProperty.GetAsync(turnContext, () => string.Empty);
if (!string.IsNullOrEmpty(userConfigSettings))
{
escapedSettings = Uri.EscapeDataString(userConfigSettings);
}

return new MessagingExtensionResponse
{
ComposeExtension = new MessagingExtensionResult
{
Type = "config",
SuggestedActions = new MessagingExtensionSuggestedAction
{
Actions = new List<CardAction>
{
new CardAction
{
Type = ActionTypes.OpenUrl,
Value = "https://<your-tunnel-url>/searchSettings.html?settings={escapedSettings}",
},
},
},
},
};
}

```

The following response is the configuration response that appears when the user interacts with the compose extension:

```json
{
"composeExtension": {
"type": "config",
"suggestedActions": {
"actions": [
{
"type": "openUrl",
"value": "https://<your-tunnel-url>/searchSettings.html?settings="
}
]
}
}
}
```

:::image type="content" source="~/assets/images/configuration-response-me.png" alt-text="Screenshot shows the configuration response for message extension.":::

## Receive and respond to queries

Expand Down