Forum Discussion

marcusyoung's avatar
marcusyoung
Copper Contributor
Jul 22, 2020
Solved

Microsoft Teams Adaptive Card Not Opening URL

I created a messaging extension that creates an pop up adaptive card that gives three options and opens a link based on the option chosen. Currently I just want the Open Sync Room button to open up to an external website, but the button doesn't do anything.

This is my code for the adaptive card.

 

function syncRoom(context, action){
    const syncRoomList = [
        { name: 'Room 1' },
        { name: 'Room 2' },
        { name: 'Room 3' },
    ]
    const choices = [];
    syncRoomList.forEach(el => choices.push({ title: el.name, value: el.name }))
    const adaptiveCard = CardFactory.adaptiveCard({
        actions: [{
          title: 'Open Sync Room',
          type: "Action.OpenUrl",
          url: 'kloud.com'
        }],
        body: [
          { text: 'Sync Rooms', type: 'TextBlock', weight: 'bolder'},
          { choices, id: 'MultiSelect', style: 'expanded', type: 'Input.ChoiceSet' },
        ],
        type: 'AdaptiveCard',
        version: '1.0'
      });

      return {
        task: {
          type: 'continue',
          value: {
            card: adaptiveCard,
            height: 450,
            title: 'Sync Room List',
            url: null,
            width: 500
          }
        }
      };
}

 

 

4 Replies

    • marcusyoung's avatar
      marcusyoung
      Copper Contributor

      subhasish-MSFT, Thanks for your help, It worked! Another question, how do I access the option that I have chosen in the card? Ideally I'd like the open sync room button to go to a different website depending on what option is chosen. Is there a way to do this?

      • subhasish-MSFT's avatar
        subhasish-MSFT
        Former Employee

        marcusyoung ,

        Adaptive card "OpenURL" action can not be modified with selected value. You could keep three different buttons with different URLs. 

        Or you could render a HTML page inside the task module and modify the button URL based on user selection of choice. 

Resources