I will be posting several post on my experience while developing on Microsoft Teams/Bot framework. This begin with my favorite feature DeepLink format which enables you to Navigate to the Tab app from the Bot.
Microsoft has not officially documented the deepLink to Static Tab. The work around is quite useful.
Below is the format for deeplink to static tab:
https://teams.microsoft.com/l/entity/28:{botID}/{tabEntityID}?context={sereliazedContextModel}&conversationType=chat
where
botId= Registered BotId
tabEntityID= entityId given in the manifest file for static Tab.
sereliazedContextModel= context object in the format as described in Generating a deep link to your tab .
In the context object you can use subEntityID to pass custom json data object which you can read in the Tab.
I had created following extension method for generating deeplink for Static Tab and Team Tab.
************************
public static string GetDeepLink(this Activity activity, CustomData customData, string subEntityName)
{
bool isPrivateConversation = false;
TeamsChannelData channelData = activity.GetChannelData<TeamsChannelData>();
string channelID = string.Empty;
if (channelData != null)
{
if (channelData.Team == null)
{
isPrivateConversation = true;
channelID = string.Empty;
}
else
{
isPrivateConversation = false;
channelID = channelData.Channel.Id;
}
}
string deepLink = string.Empty;
var appID = BotConstants.BotAppID;
var entityID = "DeepLinkTab";//should be same as manifest
var webUrl = BotConstants.BaseURl;
var label = HttpUtility.UrlEncode("DeepLink");
var objContext = HttpUtility.UrlEncode(JsonConvert.SerializeObject(
new
{
subEntityId = $"{JsonConvert.SerializeObject(customData)}",
canvasUrl = HttpUtility.UrlEncode(BotConstants.BaseURl),
channelId = channelID
}));
var tenantID =activity.GetTenantId();
if (!isPrivateConversation)
deepLink = $"https://teams.microsoft.com/l/entity/{appID}/{entityID}?webUrl={webUrl}&label={label}&context={objContext}&tenantId={tenantID}";
else
deepLink = $"https://teams.microsoft.com/l/entity/28:{appID}/{appID}?context={objContext}&conversationType=chat";
return deepLink;
}
*********************************
Thank you for reading through this. I hope you found it useful.