Adaptive Card - Action.OpenUrl Does Nothing

GermanPearls 21 Reputation points
2022-11-01T12:06:05.667+00:00

Adaptive Card in custom Teams Tab app has an Action.OpenUrl action with an external https link.

Card renders but nothing happens when the action button is clicked. No url opens, no error, nothing in console.

What's wrong?

Here's the adaptive card:

{  
    "type": "AdaptiveCard",  
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",  
    "version": "1.4",  
    "body": [  
        {  
            "type": "Container",  
            "items": [  
                {  
                    "type": "TextBlock",  
                    "text": "File Name",  
                    "wrap": true,  
                    "size": "Large",  
                    "id": "file-name"  
                },  
                {  
                    "type": "TextBlock",  
                    "text": "File description",  
                    "wrap": true,  
                    "id": "file-desc"  
                },  
                {  
                    "type": "Image",  
                    "url": "https://statics.teams.cdn.office.net/evergreen-assets/apps/teams_dev_app_largeimage.png",  
                    "size": "large",  
                    "selectAction": {  
                        "type": "Action.OpenUrl",  
                        "title": "Open File",  
                        "url": "https://www.google.com"  
                    },  
                    "id": "file-thumbnail"  
                }  
            ]  
        }  
    ],  
    "actions": [  
        {  
            "type": "Action.OpenUrl",  
            "title": "Open File",  
            "url": "https://www.google.com",  
            "id": "file-link"  
        }  
    ]  
}  

And how it's rendered:

import * as AdaptiveCards from "adaptivecards";  
  
export default function showAdaptiveCard(fl) {     
    let adaptiveCard = new AdaptiveCards.AdaptiveCard();  
    adaptiveCard.hostConfig = new AdaptiveCards.HostConfig({  
        //add options  
    });  
    adaptiveCard.onExecuteAction = function(action) {  
         alert("should be opening url");  
    }  
    adaptiveCard.parse(card);  
    let renderCard = adaptiveCard.render();  
    return renderCard;  
}  
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,923 questions
0 comments No comments
{count} votes

Accepted answer
  1. Nivedipa-MSFT 2,806 Reputation points Microsoft Vendor
    2022-11-02T05:48:57.24+00:00

    @GermanPearls
    You have to provide your own custom handling code for action.

    We have added following code and then openurl is working fine at our end.

       adaptiveCard.onExecuteAction = function (action) { window.open(action.url, '_blank') }  
    

    Please refer below video for reference:
    recording-2022-11-08-16-10-32.webm

    Thanks,
    Nivedipa


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.


0 additional answers

Sort by: Most helpful