Introduction
Deep Linking allows uses tor navigate within your apps. Your app can have MS Teams development instance like Bot, Messaging Extension, or Flow Bot send the message notification to user for an important activity. Deep Link navigates the user to the tab so that the user can view more details about activity.
Deep Linking with Tab
Deep Links can be created for Teams entities. In a typical scenario, it is used to create a link that navigates to content and information within your tab. It reduces the context switch. It keeps the user within Teams context without refreshing.
Note
The tab can be defined at Personal Tab with personal scope, Channel or Group Tab with teams or group scope.
The following format can be used for deep links in Bot, Connector, Messaging Extension Cards.
https://teams.microsoft.com/l/entity/<appId>/<entityId>?webUrl=<entityWebUrl>&label=<entityLabel>&context=<context>
The query parameters are,
- appId
The ID from your manifest; for example, "fe4a8eba-2a31-4737-8e33-e5fae6fee194" - entityId
The ID for the item in the tab, which you provided when configuring the tab; for example, "id123" - entityWebUrl or subEntityWebUrl
An optional field with a fallback URL to use if the client does not support rendering the tab; for example, "https://tasklist.example.com/123" or "https://tasklist.example.com/list123/task456" - entityLabel or subEntityLabel
A label for the item in your tab, to use when displaying the deep link; for example, "Task List 123" or "Task 456" - context
A JSON object containing the following fields: - subEntityId
An ID for the item within the tab; for example, "task456" - channelId
The Microsoft Teams channel ID that is available from the tab context; for example, "19:cbe3683f25094106b826c9cada3afbe0@thread.skype". This property is only available in configurable tabs with a scope of "team". It is not available in static tabs, which have a scope of "personal".
To implement this, you can "copy link" action from Tab or action item. You can call this url on button click, which designed via adaptive cards. when you call or click the button which is configured with copy link based url. It will gte back into same context and your tab will be reloaded.
Note
This deep link is different from the link provided by the copy link tab menu, its just generate deep link the points to tab.
- Navigate to Channel Tab, which you want to connect as deep link.
- Click on the "..." top right parllel to tab name.
- Click to "Copy link to tab"
Sample Url will be generate,
https://teams.microsoft.com/l/entity/b702977d-06e1-42cc-9166-25ad4d39a9f9/_djb2_msteams_prefix_1145688105?context=%7B%22subEntityId%22%3Anull%2C%22channelId%22%3A%22<<channel id>>%40thread.tacv2%22%7D&groupId=<<group id>>&tenantId=<<tenant id>>
Note
Sub Entitiy Id can used to pass as parameterize value, if we need to simply navigate to tab, In that scenario it can be used as null.
Deep Link to tab embed into below adaptive Card, which used into power automate to send notification, On click on button, it will navigate to Tab as well as pass parameterize url.
- {
- "type": "AdaptiveCard",
- "version": "2.0",
- "body": [
- {
- "type": "TextBlock",
- "text": "New Ticket Created",
- "weight": "Bolder"
- },
- {
- "type": "FactSet",
- "facts": [
- {
- "title": "Ticket ID",
- "value": "@{triggerOutputs()?['body/ID']}"
- },
- {
- "title": "Ticket Detail",
- "value": "@{triggerOutputs()?['body/Title']}"
- },
- {
- "title": "RequestedBy",
- "value": "@{triggerOutputs()?['body/RequestorName/DisplayName']}"
- },
- {
- "title": "Severity",
- "value": "@{triggerOutputs()?['body/Severity/Value']}"
- },
- {
- "title": "Category",
- "value": "@{triggerOutputs()?['body/Category/Value']}"
- }
- ],
- "spacing": "Medium"
- },
- {
- "type": "ActionSet",
- "actions": [
- {
- "type": "Action.OpenUrl",
- "title": "View Ticket",
- "url": "https://teams.microsoft.com/l/entity/b702977d-06e1-42cc-9166-25ad4d39a9f9/_djb2_msteams_prefix_1145688105?context=%7B%22subEntityId%22%3A@{triggerOutputs()?['body/ID']}%2C%22channelId%22%3A%2219%3A123c0abe7f0041c68066801eb8a0f8d2%40thread.tacv2%22%7D&groupId=e8312347-f8cd-4177-8661-88b335dab65b&tenantId=4cd94c60-104d-4a43-b441-e735fc34830b",
- "style": "positive"
- }
- ]
- }
- ],
- "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
- }
Package needed to import,
- import * as microsoftTeams from "@microsoft/teams-js";
Initialize into constructor,
- microsoftTeams.initialize();
- public componentWillMount() {
- microsoftTeams.getContext(teamsContext => {
- this.itemId = teamsContext.subEntityId;
- });
- }
How easy and quick it was to build a custom Custom Deep Link to Tab.
I hope you have enjoyed and learned something new in this article and Happy Learning !!