Exercise - Creating an IoT Alert

Create a flow

In this task, you'll create a flow that will register a device.

  1. In Microsoft Dynamics 365, select the drop-down arrow next to Dynamics 365, and then select Connected Field Service.

    Connected Field Service

  2. Select the Site Map button to expand the navigation, and select Customer Assets.

    Customer Assets

  3. Select Flow, and then select Create a flow.

    Create a flow

  4. Select Sign in.

    Sign in button

  5. Enter your credentials.

  6. On the My flows tab, select Create from blank.

    Create from blank button

  7. Select Create from blank again.

    Create from blank button

  8. Search for Common Data Service, and select Common Data Service – When a record is selected in the search results.

    Common Data Service – When a record is selected

  9. In the Organization Name field, select Default.

  10. In the Entity Name field, select Customer Assets.

  11. Select +New step.

    New step button

  12. Select Add an action.

    Add an action

  13. Search for Create a device, and select Azure IoT Central – Create a device in the search results.

    Azure IoT Central – Create a device

  14. Select Sign in.

    Sign in button

  15. Sign in by using the credentials that you used to create the Microsoft IoT Central application.

  16. Select Accept.

    Accept button

  17. In the Application field, enter Smart Trash Can.

  18. In the Device Template field, select the template that you created.

  19. Click in the Display Name field, and then select Name on the Dynamic content tab.

    Name

  20. In the Device Simulated field, select Yes.

  21. Select +New step, and then select Add an action.

    Add an action

  22. Search for Common Data Service, and select Common Data Service - Update a record in the search results.

    Common Data Service - Update a record

  23. In the Organization Name field, enter Default.

  24. In the Entity Name field, enter Customer Assets.

  25. Click in the Record identifier field, and then select Customer Asset on the Dynamic content tab.

    Customer Asset

  26. Select Show advanced options.

    Show advanced options button

  27. Click in the Device ID field, and then select Device ID on the Dynamic content tab.

    Device ID

  28. Select +New step, and then select Add an action.

    Add an action

  29. Search for Common Data Service, and select Common Data Service - Create a new record in the search results.

    Common Data Service - Create a new record

  30. In the Organization Name field, enter Default.

  31. In the Entity Name field, enter IoT Devices.

  32. Click in the Name field, and then select Name on the Dynamic content tab.

  33. Select Show advanced options.

    Show advanced options button

  34. Click in the Device ID field, and then select Device ID on the Dynamic content tab.

    Device ID

  35. Scroll up, and rename the flow Register Device.

    Register Device

  36. Select Save to save the flow.

    Save button

Test the registering device

  1. Return to your Connected Field Service application, and go to Customer Assets.

  2. Select New.

    New button

  3. In the Name field, enter Test Device, and then select Save.

    Save button

  4. Select Flow, and then select the flow that you created.

    Flow

  5. Select Continue.

    Continue button

  6. Select Done.

    Done button

  7. Refresh the page.

    The flow should enter a value in the Device ID field.

    Device ID field

Create IoT Alerts

In this exercise, you'll create an IoT Alert for the trash container pickup request.

Create Pickup Request Alert

  1. Go to Microsoft IoT Central, and open the left navigation.

    Open the navigation

  2. Select Device Explorer.

    Device Explorer

  3. Open the device that was created by the flow.

    Open the device

  4. On the Rules tab, select New Rule.

    New Rule

  5. Select Event.

    Event

  6. In the Name field, enter Pickup Requested, and the select the Add Conditions button (the plus sign).

    Add Conditions button

  7. In the Measurement field, select Ready for Pickup, and then select Save.

    Save button

  8. Select the Add Actions button (the plus sign).

    Add Actions button

  9. Select Microsoft Flow.

    Microsoft Flow

  10. Select Sign in.

    Sign in button

  11. On the My flows tab, select Create from blank.

    Create from blank button

  12. Select Create from blank again.

    Create from blank button

  13. Search for IoT Central, and select Azure IoT Central - When a rule is fired in the search results.

    Azure IoT Central - When a rule is fired

  14. In the Application field, select Smart Trash Can.

  15. In the Rule field, select Pickup Requested.

  16. Select +New step.

    New step button

  17. Select Add an action.

    Add an action

  18. Search for Common Data Service, and select Common Data Service - List records in the search results.

    Common Data Service - List records

  19. In the Organization Name field, select Default.

  20. In the Entity Name field, select Customer Assets.

  21. Select Show advanced options.

    Show advanced options button

  22. In the Filter Query field, enter msdyn_deviceid eq '', and then put the curser inside the single quotation marks.

    Filter Query field

  23. On the Dynamic content tab, select Device ID.

    Device ID

  24. Select New Step, select More, and then select Add an apply to each.

    Add an apply to each

  25. On the Dynamic content tab, select value.

    value

  26. Select Add an action.

    Add an action button

  27. Search for Common Data Service, and select Common Data Service - Create a new record in the search results.

    Common Data Service - Create a new record

  28. In the Organization Name field, enter Default.

  29. In the Entity Name field, enter IoT Alerts.

  30. Click in the Description field.

    Description field

  31. On the Dynamic content tab, select Device Name. Then, in the Description field, type a hyphen (-) after it.

    Device Name

  32. On the Dynamic content tab, select Rule Name, and then select Show advanced options.

    Show advanced options button

  33. Click in the Alert Data field, and then select the Expression tab.

    Expression tab

  34. Enter utcNow(), and then select OK.

    OK button

  35. Click in the Alert Time field, and then select Timestamp on the Dynamic content tab.

    Timestamp

  36. Click in the Device ID field, and then select Device ID on the Dynamic content tab.

    Device ID

  37. Click in the Customer Asset field, and then select Customer Asset on the Dynamic content tab.

    Customer Asset

  38. Scroll up, and rename the flow Create Alerts.

    Create Alerts

  39. Select Save to save the flow.

    Save button

Test alerts

  1. Return to Microsoft IoT Central, open the test device that was created by the flow, and then select the Measurements tab.

    Measurements tab

    The simulator should generate a new pickup request every few minutes.

    Pickup requests in the simulator

  2. Go to your Connected Field Service application.

  3. On the Menu button, select IoT Alerts.

    IoT Alerts

    You should see the alerts that are generated by the simulator.

    Alerts generated by the simulator