AdaptiveCards icon indicating copy to clipboard operation
AdaptiveCards copied to clipboard

[.NET] Deeplinks aren't behaving as expected in Teams

Open brettjenkins opened this issue 7 years ago • 10 comments

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);

brettjenkins avatar Nov 14 '19 21:11 brettjenkins

@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

shalinijoshi19 avatar Nov 18 '19 20:11 shalinijoshi19

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.

brettjenkins avatar Nov 18 '19 20:11 brettjenkins

This issue has been automatically marked as stale because it has not had any activity for 5 days.

ghost avatar Nov 29 '19 18:11 ghost

@dclaux thoughts on this one real quick ? Thanks

shalinijoshi19 avatar Apr 17 '20 15:04 shalinijoshi19

@dclaux / @matthidinger thoughts?

shalinijoshi19 avatar Apr 22 '20 22:04 shalinijoshi19

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

matthidinger avatar Apr 23 '20 15:04 matthidinger

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?

siduppal avatar Apr 23 '20 18:04 siduppal

@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"),
});

Subhasish-msft avatar Apr 24 '20 18:04 Subhasish-msft

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 avatar May 08 '20 20:05 brettjenkins

@brettjenkins , I am closing this. If you still face any issue, please reopen it.

Subhasish-msft avatar May 11 '20 04:05 Subhasish-msft