Forum Discussion
diegoSpace
Feb 19, 2020Brass Contributor
Team Channel: Card with button. Specific URL for each user?
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
- Gousia_Begum
Microsoft
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.
- diegoSpaceBrass Contributor
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
- Gousia_Begum
Microsoft
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.