razormicrosoft-teamsmicrosoft-graph-teamsadaptive-cards

Get User Response from Adaptive Card in an ASP.NET Razor Web App


I am trying to send an adaptive card into a teams chat from a Razor application by utilising the Graph API SDK.

I can see documentation to send the card listed on the Microsoft docs here. No dramas.

I want to send a card with one button "Acknowledge". When the user clicks acknowledge, I want to send a response back to my application to say the user has clicked this button. Is this possible? I can't find any documentation anywhere. Is anyone able to link me some documentation, tell me if this is possible, or provide another solution?


Solution

  • Yes, as you've linked, it's possible to send the card message itself via Graph, but you're limited in terms of how to deal with the response, especially in a "web app" scenario. If you're ok with them clicking a button that loads your web page in a browser, then you can simply use a "Open Url" type of card action button (see here for more: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions?tabs=json). If you want the button to perform an action within Teams though, then you need to use a bot behind the scenes. You can consider the "Flow" bot, as part of a Power Automate workflow, or you can build your own bot to receive the message and take the relevant action. Both of these are broader topics than I can dive into here but you can see for instance https://learn.microsoft.com/en-us/power-automate/create-adaptive-cards and https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/command-bot-in-teams?tabs=jsts1%2Cjs%2Cjsts2