Extend a Teams message extension across Microsoft 365
發行項
Message extensions allow users to interact with your web service using buttons and forms. Users can search or initiate actions in an external system from Microsoft Teams and Outlook by extending your Teams apps across Microsoft 365. There are two types of message extensions:
Search-based message extensions: Allow users to search an external system and share results through the compose message area of the client.
Action-based message extensions: Allow users with a modal pop-up to collect or display information, process the interaction, and send the information back to the client as a rich card.
注意
Teams search-based message extensions are generally available for Outlook and action-based message extensions are available in preview for Outlook.
Outlook mobile users on Android and iOS can receive and take actions on cards from your apps that were sent to them by users on Outlook on the web and Outlook for Windows.
Teams message extension across Microsoft 365 also supports link unfurling that display cards to launch Stageview and dialogs.
Prerequisites
To extend your Teams message extension to Outlook, ensure the following:
Check for message extensions support within Outlook for Windows desktop, web, and mobile, see the support table in extend Teams apps across Microsoft 365.
To extend your Teams message extension to Outlook, you can either build a new message extension app with Teams Toolkit or extend an existing Teams message extension app to Outlook.
You can build a Teams message extension app for Outlook through Teams Toolkit extension for Visual Studio Code. To build a message extension app for Outlook, ensure the following:
Select Command Palette... under the View option or Ctrl+Shift+P.
Select Teams: Create a New App.
Select Message Extension from the dropdown list.
Select Custom Search Results to download the sample code for a Teams search-based message extension using the latest app manifest (previously called Teams app manifest).
You can also download the sample code from the left pane, under DEVELOPMENT, select View Samples. A Samples tab appears, in the search field enter NPM Search Connector.
Select a preferred programming language.
Select a location on your local machine for the workspace folder and enter your application name.
Select Command Palette... under the View option or Ctrl+Shift+P.
Enter Teams: Provision to create the relevant app resources, such as Azure App Service, App Service plan, Azure Bot, and Managed Identity, in your Azure account.
Select a subscription and a resource group.
Select Provision. Alternatively, you can select Provision under the LIFECYCLE section of the extension.
Select Command Palette... under the View option or Ctrl+Shift+P.
Enter Teams: Deploy to deploy the sample code to the provisioned resources in Azure and start the app. Alternatively, you can select Deploy under LIFECYCLE section of the extension.
Select Deploy.
Open Visual Studio Code.
Select Command Palette... under the View option or Ctrl+Shift+P.
Select Teams: Create a New App.
Select Message Extension from the dropdown list.
Select Collect Form Input and Process Data to download the sample code for a Teams action-based message extension using the latest app manifest (previously called Teams app manifest).
Select preferred programming language.
Select a location on your local machine for the workspace folder and enter your application name.
Select Command Palette... under the View option or Ctrl+Shift+P.
Enter Teams: Provision to create the relevant app resources, such as Azure App Service, App Service plan, Azure Bot, and Managed Identity, in your Azure account.
Select a subscription and a resource group.
Select Provision. Alternatively, you can select Provision under the LIFECYCLE section of the extension.
Select Command Palette... under the View option or Ctrl+Shift+P.
Enter Teams: Deploy to deploy the sample code to the provisioned resources in Azure and start the app. Alternatively, you can select Deploy under LIFECYCLE section of the extension.
To ensure your app always provides customers with high-quality experiences, you can tailor your app's behavior in applicable Microsoft 365 hosts, or omit it from surfacing in contexts that you're not ready to support. Use app manifest to specify any dependency relationships across capabilities of your app, and specific runtime requirements of your static tabs, message extensions, and bots.
In Microsoft Teams, a message extension consists of a web service that you host and an app manifest, which defines where your web service is hosted. The web service takes the advantage of Bot Framework SDK messaging schema and secure communication protocol through a Teams channel registered for your bot.
For users to interact with your message extension from Outlook, you need to enable the Microsoft 365 channel for your Azure bot resource of the message extension app.
注意
If you've previously enabled the Outlook channel for your bot, you'll need to enable the Microsoft 365 channel for your message extension to function correctly in Microsoft Outlook. The Outlook channel is no longer used for message extensions running in Outlook and can be disabled.
Under Available channels, select Microsoft 365 channel.
Select Apply.
Confirm that your Microsoft 365 channel is listed along with Microsoft Teams in your bot's Channels pane.
Update Microsoft Entra app registration for SSO
注意
You can skip this step if you're building an app for Outlook using Teams Toolkit, as the scenario doesn't involve Microsoft Entra single sign-on authentication.
Microsoft Entra single sign-on (SSO) for message extensions works the same way in Outlook as it does in Teams. However, you need to add several client application identifiers to the Microsoft Entra app registration of your bot in your tenant's App registrations portal.
Sign in to Azure portal with your sandbox tenant account.
Select App registrations.
Select the name of your application to open its app registration.
Select Manage > Expose an API.
In the Authorized client applications section, ensure all the following Client Id values are listed:
Microsoft 365 client application
Client ID
Teams desktop and mobile
1fec8e78-bce4-4aaf-ab1b-5451cc387264
Teams web
5e3ce6c0-2b1f-4285-8d4b-75ee78787346
Microsoft 365 web
4765445b-32c6-49b0-83e6-1d93765276ca
Microsoft 365 desktop
0ec893e0-5785-4de6-99da-4ed124e5296c
Microsoft 365 mobile
d3590ed6-52b3-4102-aeff-aad2292ab01c
Outlook desktop
d3590ed6-52b3-4102-aeff-aad2292ab01c
Outlook Web Access
bc59ab01-8403-45c6-8796-ac3ef710b3e3
Outlook mobile
27922004-5251-4030-b22d-91ecd9a37ea4
Upload your custom app in Teams
Upload your updated message extension (app package) into Teams. After you complete, message extension appears in your installed Apps from the compose message area.
Create a .zip file with app manifest and app icons.
Go to Microsoft Teams and sign in using your sandbox tenant account.
Select Apps > Manage your apps > Upload an app.
Select the Upload a custom app option, select your .zip file, and install (Add) it to your Teams client.
After it's uploaded through Teams, your message extension is available in Outlook for Windows desktop and web.
Preview your message extension in Outlook
Here's how to test your message extension running in Outlook on the web. To preview your app running in Outlook on the web, follow these steps:
Sign in to outlook.com using your test tenant credentials.
Select New message.
Select Apps on the ribbon.
Your message extension is listed. You can invoke it from there and use it just as you would while composing a message in Teams.
Debugging
As you debug your message extension, you can identify the source (originating from Teams versus Outlook) of bot requests by the channelId field of the Activity object. When a user performs a query, your service receives a standard Bot Framework Activity object. One of the properties in the Activity object is channelId, which has the value of msteams or m365extensions, depending on where the bot request originates. For more information, see search based message extensions SDK and action based messaging extensions SDK.
Limitations
While your updated message extension continues to run in Teams, you must be aware of the following limitations:
Message extensions in Outlook are supported only in the compose context. In Teams app manifest, message extension contexts such as commandBox and message aren't supported in Outlook.
Action-based message extensions that send cards into the compose box are supported in Outlook. However, using bots to deliver cards isn't supported. In this scenario, you can convert your message extension to send cards into the compose box in Outlook.
You can't insert more than five Adaptive Cards in an email.
Card actions of type messageBack, imBack, invoke, and signin aren't supported. openURL is the only supported card action.
Adaptive Card actions are supported. For Action.Submit only stageview and taskmodule launching is supported.
注意
When you test an app with link unfurling, ensure that you remove the app manually after testing. If multiple apps are monitoring the same domain, the app installed most recently might not be invoked to unfurl the link in Outlook, as it would in Teams.
Learn how to build message extensions that allow users to interact with external services within their flow of work in Microsoft Teams and Microsoft 365 Copilot.
Learn how to edit and preview app manifest in local and remote environments, customize app manifest in Visual Studio Code, and ways to validate and update app.
Learn about inadequate app description, improper screenshots, Partner Center and app manifest mismatch, valid domains violation, or broken app functionality.