[.NET] Deeplinks aren't behaving as expected in Teams
Platform
What platform is your issue or question related to? (Delete other platforms).
- .NET
Author or host
Author
If you're an author, who are you sending cards to?
Microsoft Teams
Version of SDK
NuGet 1.2.4
Details
I think I've found a bug with how adaptive cards in teams handle Internal DeepLinks.
If I make my bot send a simple non-adaptivecard message that uses a deeplink that links to a channel using the format [Text](deeplink) then it works fine, clicking the link in Teams takes you straight to the channel without leaving teams, which is the desired behaviour.
If I use the same link in an adaptivecard, again with the format [Text](deeplink) - clicking the resulting link in Teams causes a browser to be opened, which then opens a popup asking if I want to open in Teams, if I say yes, it will open the channel in my Teams app - so it works, but the experience isn't as smooth as when you're not using adaptive cards.
Here is an example below, the first line will send a message in Teams and it will work fine, but the card version will go via the browser.
I've censored the groupid and tenantid, don't care so much about the channelid because it's a test channel
The code below is also just hacky test code
var link = "https://teams.microsoft.com/l/channel/19%3ab974293647e040a587221882fa67f2a0%40thread.skype/Incident+1+-+fff+2019-12-14?groupId=GROUPID&tenantId=TENANTID";
await turnContext.SendActivityAsync(MessageFactory.Text($"[fff]({link.Replace("+", "%2520")})"),
cancellationToken);
AdaptiveCard card = new AdaptiveCard();
card.Body.Add(new AdaptiveTextBlock()
{
Text = $"[tttt]({link.Replace("+", "%2520")})",
Size = AdaptiveTextSize.Large,
Weight = AdaptiveTextWeight.Bolder
});
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
turnContext.Activity.Attachments = new List<Attachment>();
turnContext.Activity.Attachments.Add(attachment);
await turnContext.SendActivityAsync(turnContext.Activity, cancellationToken);
@brettyj you are trying to render this on Teams Desktop i am assuming? @dclaux thoughts on this one? How does this scenario work again? Is this something that Teams controls via the resp Action handler or is this something that AdaptiveCards renderer handles? Also @siduppal / @clearab FYI
Hey, yeah @shalinijoshi19 this is on Teams Desktop - I haven't actually tested it on mobile. It only seems to be an issue if I render the link via an adaptive card.
This issue has been automatically marked as stale because it has not had any activity for 5 days.
@dclaux thoughts on this one real quick ? Thanks
@dclaux / @matthidinger thoughts?
I think @siduppal would have to help with this one. The .NET lib is just creating the JSON payload as built (@brettyj if you can post the JSON response that would also help), but Teams decides how links are opened. It seems like in other card types (e.g., HeroCard) they detect if the URL starts with teams.microsoft.com and if so make the app respond instead of opening a browser
For Adaptive Cards, deeplinks within Teams that don't jump out to browser are only supported via Action.OpenUrl buttons at this time.
@Wajeed-msft can you take a look?
@brettyj , To use deeplink within Teams, You can use OpenUrl action type in adaptive card. Here is the sample code.
card.Actions.Add(new AdaptiveOpenUrlAction()
{
Title = "Link Text",
Url = new Uri("link_url"),
});
Thanks for the reply. I'll take a look when I get chance, the project I was working on has been put on the back burner due to reasons, but I'll try and test this to confirm if it fixes the initial issue.
@brettjenkins , I am closing this. If you still face any issue, please reopen it.