A few months ago my esteemed colleague Patrick LeBlanc published a great video showing how you could use Power Automate (formerly known as Microsoft Flow) to send an email when a Power BI alert is triggered. This post is going to cover almost the same ground, except that I’m going to show you how to send an alert to a user via Teams and instead of dynamically generating text for the message I’m going to use an Adaptive Card to format the alert data.
Although Adaptive Cards have been around for a while now, I’m slightly embarrassed to admit that I only learned about them a few weeks ago when I read this blog post. Full details about Adaptive Cards can be found at https://adaptivecards.io/; for those of you too lazy to click the link, here’s the official description and a short explainer video:
Adaptive Cards are platform-agnostic snippets of UI, authored in JSON, that apps and services can openly exchange. When delivered to a specific app, the JSON is transformed into native UI that automatically adapts to its surroundings. It helps design and integrate light-weight UI for all major platforms and frameworks.
There’s documentation on how Adaptive Cards can be used in Power Automate here and a comprehensive video here:
When I first saw them I knew that they would be perfect way to send Power BI alerts to people. Here’s a simple example showing how to use them for this purpose.
First of all, I set up a simple Power BI report and dashboard containing a card visual with a value in and created an alert on it, just as Patrick shows in his video. Then I went to the Adaptive Cards designer at https://adaptivecards.io/designer/ and created an Adaptive Card to display alert data:
Then I created a simple Flow in Power Automate with the “When a data driven alert is triggered” trigger (again, just as Patrick shows) but then used the “Post your own adaptive card as the Flow bot to a user” action:
I pasted the JSON definition of the Adaptive Card I created in the designer earlier into the message of this action, and made it dynamic:
…and having done that, once the alert was triggered in Power BI I got a message in Teams from the Flow bot with the alert data shown in my Adaptive Card:
Even better, as the blog post I referred to earlier explains, Power Automate now has a preview feature that allows you to wait for a response from an Adaptive Card that collects user input as well as displays data. Imagine a scenario where:
- A Power BI alert is triggered because the number of widgets in your warehouse is getting dangerously low
- This alert triggers a Flow that sends a message as an Adaptive Card to a user via Teams which not only displays the current stock level but also asks the user how many widgets to order
- The Flow waits for a response and, when it gets one, goes away and orders that number of widgets
Hmm, this sounds like a good subject for a future blog post…
About the Author:
My name’s Chris Webb, and I’m a specialist in Analysis Services, MDX, Power Pivot, DAX, Power Query and Power BI in general. I’ve been blogging about Microsoft BI for over 10 years, and racked up over 1000 posts here! I also speak at a number of conferences including SQLBits, the PASS Summit, the PASS BA Conference, SQL Saturdays and user groups.
I am a Microsoft employee, but the statements and views expressed here are mine alone.
Feel free to connect with me on LinkedIn and to follow me on Twitter.
Webb, C. (2019). Sending Power BI Alerts To Users Via Teams Using Power Automate And Adaptive Cards. Available at: https://blog.crossjoin.co.uk/2020/01/27/power-bi-alerts-teams-power-automate-adaptive-cards/ [Accessed: 14th February 2020]