Team Channel: Card with button. Specific URL for each user?

Brass Contributor

Hi,

I have a Teams bot with bot commands (personal & team). In a Team, with one of the received commands the bot sends to the team channel a Card with a button. Now this button opens a fixed URL in the pc browser ('Action.OpenUrl').

 

The URL is the same for all teams members, since the card is available for all once sent. What I would like to do is to open a different URL depending on the user who presses the button in the team channel.

 

Is it possible? I could add a task in the card, so my bot would be notified, but then I am not in the client side to open the URL...

 

Any help?

 

Thanks,

Diego

5 Replies

@diegoSpace It is not possible to specify different URL's for different users on click of a button. One way you could do this is open a taskmodule and check the user details there and open a url inside task module but that is not a reliable way and is something we do not recommend.

@Gousia_Begum I will try it, just to see if works for me. Why do you don'r recommend it?

 

As far as I understand in the docu, I must add an 'Action.Submit' in my card, correct? I have that in the card.json sent to the team channel:

"actions": [
 {
      "type": "Action.Submit",
      "title": "Test1",
      "data": {
              "msteams": {
                    "type": "invoke",
                    "value": "{\"key1\": \"value1\", \"key2\": \"value2\"}"
               }
       }
}
]

 

I receive a post in my bot ("type='invoke'), but is there any method in the API to handle it? Or must I check the 'type' and process then? Now I have that code, and I return a task to open a browser in Teams channel, but no browser is open (I get no error):

   onPostReceived(req, res) {
         if (req.body == "invoke") {
              var task = {
                  "task": {
                           type: 'continue',
                           value: {
                                    width: 500,
                                    height: 200,
                                    title: "site title",
                                    url: myUrl,
                                    fallbackUrl: myUrl
                           }
                    }
             }

             res.writeHeader(200, { "Content-Type": "application/json" });
             res.write(JSON.stringify(task));
             res.end();
         }
}

 

What am I doing wrong? 

 

Thanks,

Diego

 

@diegoSpace If you want to open a link in the browser on click of a button you need to use a Action.OpenURL action and if you want to open a task module you will need to pass a invoke action with type as "task/fetch". Please go through TaskModules and try this out.

@Gousia_Begum I read the link you mention and according to what I understood there I had the code I pasted before. Is it wrong?

 

I send to a channel a card, with an action button ("type": "Action.Submit"). When button pressed, my bot receives the HTTP post (message with type 'invoke'), and I responde with a 200 OK (with the task info)

 

But nothing happens (no popup task is open). Maybe I am not returning properly the Task:

 

var task = {
        "task": {
              type: 'continue',
                value: {
                      width: 500,
                      height: 220,
                      title: "Test",
                      url: sUrlNotLogged,
                      fallbackUrl: sUrlNotLogged
                }
        }
}

res.writeHeader(200, { "Content-Type": "application/json" });
res.write(JSON.stringify(task));
res.end();

 

Or I missunderstood the documentation...

 

Thanks for your help

@Gousia_Begum I would really appreciate any idea... Thanks!!