Forum Discussion
Adaptive card popup
Yes, it is possible to build an Adaptive Card with a button in a Teams channel that opens a popup window with an embedded Power App. This can provide a more user-friendly experience compared to pointing the button to a tab in the channel.
To achieve this, you can use Task Modules in Microsoft Teams. Task modules allow you to create modal pop-up experiences in your Teams application. In the pop-up window, you can run your own custom HTML or JavaScript code or display an Adaptive Card.
Here's an example of how you can implement this:
- Create an Adaptive Card with a button:
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Click the button to open the Power App"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Open Power App",
"data": {
"action": "openPowerApp"
}
}
]
}
- In your bot or message extension, handle the
openPowerApp
action:
protected override async Task<TaskModuleResponse> OnTeamsMessagingExtensionSubmitActionAsync(ITurnContext<IInvokeActivity> turnContext, MessagingExtensionAction action, CancellationToken cancellationToken)
{
if (action.CommandId == "openPowerApp")
{
var taskModule = new TaskModuleContinueResponse
{
Type = "continue",
Value = new TaskModuleTaskInfo
{
Title = "Power App",
Height = "medium",
Width = "medium",
Url = "https://your-power-app-url"
}
};
return taskModule.ToTaskModuleResponse();
}
return null;
}
- When the user clicks the "Open Power App" button, the
openPowerApp
action is triggered. In the bot or message extension code, you can handle this action and return aTaskModuleContinueResponse
with the URL of your Power App. This will open the Power App in a popup window.
By using Task Modules and Adaptive Cards, you can create a button in a Teams channel that opens a popup window with an embedded Power App. This provides a more user-friendly experience for your users.
Ref Doc: Task modules - Teams | Microsoft Learn
Thanks,
Nivedipa
-------------------------------------------------------------------------
If the response is helpful, please click Mark as Best Response and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
- oskarkuusAug 21, 2023Brass ContributorThank you for your response.
Step 2 confuses me a bit. I think this is aoutside of my knowledge...
All i have done so far is to create the adaptive card.
Add a button and i know how to add the url to the button. But the step of creating a bot/app (message extension) where this code should be... i dont know?- Nivedipa-MSFTAug 21, 2023Microsoft
oskarkuus - For messagin extension you can refer below document to get details:
https://learn.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/what-are-messaging-extensions?tabs=dotnet
Please let us know if you have any further query here?- Nivedipa-MSFTAug 24, 2023Microsoft
oskarkuus - Could you please share your valuable feedback via Microsoft Teams Developer Community Response Feedback.