Microsoft Fabric Updates Blog

Acting on Real-Time data using custom actions with Data Activator

Being able to make data driven decisions and act on real-time data is important to organizations because it enables them to either avert crisis in systems that monitor product health and take other actions based on their requirements. For example, a shipping company may want to monitor their packages and act in real-time when the temperature of the packages becomes too hot. One way of monitoring and acting on data is to use Data Activator, which is a no-code experience in Microsoft Fabric for taking action automatically when the condition of the package temperature is detected in the data.

Let’s look at Contoso Bikes, a fictitious bike rental company that has a real-time dataset of all bikes available in the docking stations scattered across different neighborhoods in the city. They want to optimize the availability and distribution of their bikes based on the supply and demand patterns. They want to automatically trigger alerts, notifications, or workflows when certain conditions are met in the data, high or low availability of bikes in a certain neighborhood to action job requests to increase the number of available bikes at docking stations.

Using custom actions to trigger alerts with Data Activator To achieve this, you can set up custom actions with Data Activator to trigger alerts that will enable Contoso Bikes to act on the data. Custom actions in Data Activator are reusable action templates that you can use in multiple triggers, in multiple Reflex items. A custom action defines how to call a specific external system from a Data Activator trigger using a flow

1 – Set a trigger and create a custom action

An alert needs to be already set on your data, you can follow these steps to get and set one using the sample bike data.

  • Inside of your alert, set the trigger condition to select the No_Bikes property from the dataset
Figure 1: Shows selecting a field to monitor
  • Then set the condition to check when the number of bikes drops to less than 5, so that the trigger can run when the condition is met. This can also be filtered down further, for example you can add a filter that checks for a specific Neighbourhood.
Figure 2: Setting a condition to trigger an alert
  • Lastly, create a custom action by selecting Custom Action then + Create using the top navigation bar. Give your custom action a name, then add input fields which are used as input when triggering alerts and copy the connection string.
Figure 3: Creating a new custom action
  • Select Create flow in Power Automate, this will navigate to Power Automate. You can add any action then save the flow so that you can come back to Data Activator.
  • In Data Activator, scroll to the Act section and choose your custom action then fill out the required information for properties. You can create corresponding properties by using the New Property at the top navigation bar.
Figure 4: Setting the input fields of the custom action
  • Select Save.

2 – Configure a custom action in Power Automate

To trigger and send actionable alerts to Contoso Bikes employees, you can use Power Automate as a custom action. Then you will be able to have a notification that is sent to Contoso Bike with an option to mark a job request completed after the bike docking stations have been restocked.

  • In the Power Automate flow created after creating a custom action, update the When a Data Activator trigger fires with the connection string.
  • Add an action to Create Item, this will allow Contoso Bikes to receive and store job requests in a SharePoint list. Update it with the relevant fields including the ones from Data Activator, use this format to get values from the trigger triggerOutputs()?[‘body/inputFields/Bikepoint’]. You can opt to us another data source.
Figure 5: Editing Create Item action in Power Automate
  • Add an action to Post an Adaptive Card and wait for a response in a Teams channel to alert Contoso bikes and take action. Update the message property for this action with the below JSON schema.
{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.2",
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Not enough bikes at the docking stations",
                    "wrap": true,
                    "style": "heading",
                    "id": "lblDisplay"
                }
            ]
        },
        {
            "type": "TextBlock",
            "text": "Please see and increase number of bikes in the docking stations below",
            "wrap": true,
            "size": "Small",
            "weight": "Lighter",
            "color": "Default",
            "isSubtle": true,
            "id": "lblDescription"
        },
        {
            "type": "FactSet",
            "facts": [
                {
                    "title": "Bikepoint:",
                    "value": "@{triggerOutputs()?['body/inputFields/Bikepoint']}"
                },
                {
                    "title": "Neighbourhood:",
                    "value": "@{triggerOutputs()?['body/inputFields/Neighbourhood']}"
                },
                {
                    "title": "No. of bikes:",
                    "value": "@{triggerOutputs()?['body/inputFields/No of Bikes']}"
                },
                {
                    "title": "No. of Empty docks:",
                    "value": "@{triggerOutputs()?['body/inputFields/Empty Docks']}"
                },
                {
                    "title": "Street:",
                    "value": "@{triggerOutputs()?['body/inputFields/Street']}"
                },
                {
                    "title": "Job No.",
                    "value": "@{body('Create_a_job_item')?['Title']}"
                }
            ]
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.Submit",
                    "title": "Completed",
                    "id": "btnCompleted"
                }
            ]
        }
    ]
}
  • Lastly, add an action Update item to change the job request status from Not Started to Complete after the completed button on the adaptive card alert has been selected to indicate the docking stations have sufficient bikes available. Make sure to have proper naming conventions as best practice
Figure 6: A complete Power Automate flow

Summary

By creating custom actions, you can act on data in real-time and across different platforms. You can also customize the actions to suit your specific needs and scenarios. With Data Activator, you can turn your data into actions and achieve your business goals.

Other resources

Liittyvät blogikirjoitukset

Acting on Real-Time data using custom actions with Data Activator

lokakuuta 4, 2024 tekijä Jason Himmelstein

We had an incredible time in our host city of Stockholm for FabCon Europe! 3,300 attendees joined us from our international community, and it was wonderful to meet so many of you in person. Throughout the week of FabCon Europe, our teams published a wealth of valuable content, and we want to ensure you have … Continue reading “Fabric Community Conference Europe Recap”

syyskuuta 26, 2024 tekijä Guy Reginiano

Now you can set up Data Activator alerts directly on your KQL queries in KQL querysets.