Building a workflow


Workflows are a sequence of automated tasks and actions that run in response to events or conditions. BMC Helix Edge provides a user-friendly interface to design and customize workflows. By building a workflow in BMC Helix Edge, you automate and orchestrate tasks, actions, and responses based on specific events or conditions. Integrated into BMC Helix Edge, Workflow Editor provides an intuitive canvas for creating, connecting, and configuring nodes to construct your workflow.

An event or condition triggers workflows. These events originate from device data, external sources, or machine-learning anomaly detection. Identifying the triggers for your workflow is a crucial step in its creation. You configure nodes, each representing a specific action or process. These nodes define what a device must do when an event occurs. This configuration includes setting up data transformations, conditional logic, and integration with other systems or services. Workflows often interact with external systems, databases, cloud services, or BMC Helix Edge components. Nodes facilitate the seamless connection to these external entities, allowing for data exchange and collaboration.

Breakdown of a workflow

In BMC Helix Edge, workflows are key to making sense of data collected from IoT devices. Workflows orchestrate and automate various tasks and processes in the IoT ecosystem. It contains analyses and acts upon that collected data, making the system more innovative and responsive.

Use the following breakdown to show how a workflow in BMC Helix Edge comes together:

  1. The workflow starts with the device services collecting metric data from devices and contextual data from enrichment, followed by a rule or Machine Learning that detects significant events or anomalies. Imagine a fleet of wind turbines scattered across a wind farm. These turbines continuously provide data, such as temperature, oil levels, and so on.
  2. After we have this data, we must understand the data. We define rules to detect specific conditions. For example, for our turbines, we set a rule that triggers an alert if the temperature suddenly rises above a critical threshold or the oil level drops low. These rules function as our digital watchdogs.
  3. When a rule detects an anomaly or a specific condition, it generates an event. These events are like alarms that notify us that something noteworthy has occurred. You can visualize these events on a BMC Helix Dashboard or BMC Helix Operations Management user interface.
  4. But it is not just rules that generate events. Machine Learning can also detect anomalies in the data and manifest them as events. For instance, the ML model might notice unusual patterns in turbine behavior that could indicate a potential issue.
  5. As you start receiving these events, the next question arises: Can we automate handling these events, especially the repetitive ones? This area is where Node-RED Editor comes into play. Node-RED is like your automation expert.

Before deploying a workflow in a production environment, you must evaluate and validate its functionality in a controlled setting. BMC Helix Edge provides tools and environments for thorough testing to make sure the workflow performs as expected. After a workflow has been designed, configured, and evaluated, you can deploy the workflow. You continuously deployed workflows, monitored for specified events, and run actions in real time.

Before you begin

  • Make sure you have device profiles and metrics.
  • Make sure the devices are connected to the network.
  • Make sure the MQTT broker is configured and running and complete with the necessary connection details.
  • Make sure you know the data generated by devices.
  • Familiarize yourself with Node-RED, its flow creation, node usage, and configuration. To learn more about using Node-RED, see the Node RED documentationimage-2024-2-23_15-9-7.png.
  • Determine the workflow requirements, encompassing actions to automate, data transformations, and potential external integrations.
  • Set up a testing environment for thoroughly validating and testing the Node-RED workflows before deploying them in a production environment.

Subscribing to a specific event 

To subscribe to a specific MQTT topic where BMC Helix Edge publishes the oil level data, 

  1. To initiate your workflow, you must subscribe to a specific event.
  2. On the BMC Helix Edge page, select Rules and workflows > Workflow Builder.
  3. In the left pane of the Workflow builder page, select a node to build a workflow.
  4. In the Streams pane, select a data stream and in the workflow space, expand the Input category in the Node palette.
  5. From the palette, select mqtt-in.
  6. Click the Properties tab, and input the following details:

    Field name

    Description

    Server

    Select the MQTT broker server from the pre-configured options.

    Action

    Select Subscribe to single topic.

    QoS

    Determine the quality of service for MQTT. For more information, see the MQTT documentation.

    Topic

    Enter the name of the topic as {node1}/BMCEvents.

    {node1} represents the NodeId, accessible from the Device list UI.

    BMC recommends printing the subscribed event to obtain the event field names.

    Output

    Auto-detection is usually sufficient. Select the parsed JSON object because the Event is in JSON format.

    Name

    Displays the event name from the Events field.

    The following is an example of an event subscription:
    image-2024-3-13_21-20-57-1.png
    BMC Helix Edge uses the event fields from the payload. For example, the event name in the Name field is LowOilEvent:
    image-2024-3-13_21-27-30-1.png

Building and executing remediation commands

Automating remedial actions is a key objective in workflow creation. BMC Helix Edge supports two types of remedial actions: DeviceCommand and NewServiceRequest. Regardless of the type chosen, you must construct the command payload and publish the payload to the {nodeid}/BMCCommands topic. 
You must replace nodeid with the actual nodeid where the workflow operates, obtainable from the device UI listing.

The following table describes the signature of the command payload:

Command

Description

id

A unique identifier.

device_name

The name of the device.

type

The type of command. For example, NewServiceRequest, CloseServiceRequest, DeviceCommand.

execution_node_type

 The type of execution node. For example, Edge, Core.

name

 The name of the command.

command_parameters

 Parameters required for the command.

problem

 The description of the problem.

source_node

 The original node triggering the event.

severity

 The severity level of the event. 

command_uri

 The URI for the command.

event_id

 The ID of the event.

correlation_id

 The correlation ID for tracking.

created

 The time stamp of command creation. 

remediation_id

 The ID for remediation.

status

 The execution status of the command.

The following is an example payload for a work order to replenish oil (assuming BMC Digital Workplace is configured).

Important:

The command_parameters value is specific to the service and is obtained from user input in Digital Workplace. ServiceID represents the ID for the specific service definition.


json
{
  "id": "msg.payload.id",
  "correlation_id": "msg.payload.correlation_id",
  "device_name": "msg.payload.device_name",
  "name": "msg.payload.name",
  "type": "NewServiceRequest",
  "problem": "Gearbox failure due to low oil",
  "source_node": "msg.payload.source_node",
  "severity": "msg.payload.severity",
  "event_id": "msg.payload.id",
  "status": "msg.payload.status",
  "command_parameters": {
    "serviceID": "11903",
    "Fuel Level": "msg.payload.actual_value.toString()",
    "Reason for Request": "Gearbox failure again due to low oil",
    "summary": "Order Onsite Fuel Service LowOilOpen",
    "ticketType": "Work-Order"
  }
}

Make sure that the DeviceCommand payload is similar (type: DeviceCommand) and that command_parameters are specific to commands as defined by device_service.

Refer to the list of device commands in the device UI and its parameters for further details.

Using Workflow Designer

The following tasks provide high-level steps to build a workflow and generate service requests by using Node-Red. BMC recommends referring to Documentation: Node-RED.   

Building a workflow

  1. On the BMC Helix Edge page, select Rules and workflows > Workflow Builder.
    BMC Helix Edge displays the following panel:
    image-2023-11-17_14-57-10.png
  2. In the left pane of the Workflow builder page, select a node to build a workflow.
  3. In the Streams pane, select a data stream for a node, and in the workflow space, perform the following steps:
    1. To add a node input node: 
      1. Expand the Input category in the Node palette, which contains nodes that can trigger your workflow.
      2. Drag and drop an appropriate input node to the flow canvas. For example, select Inject.
    2. To add processing nodes:
      1. Expand the Function or other relevant categories in the Node palette.
      2. Drag and drop processing nodes onto the flow canvas to define how you want to process the input data or trigger events.
        These nodes can include JavaScript functions, switches, or other processing logic.
    3. To add output nodes:
      1. Expand the Output category in Node Palette.
      2. Drag and drop an output node (for example, Debug node) onto the flow canvas to view or log the output of your workflow.
        Depending on your use case, you can also connect output nodes to external systems or services.
    4. To define the data flow and logic:
      1. Connect the nodes by drawing lines between their output and input ports.
      2. Click and drag from the output port of one node to the input port of another node to create a connection.
    5. To configure the node properties:
      1. Double-click the node to open its properties panel.
      2. Configure the properties, such as input values, conditions, or actions, based on your workflow requirements.
    6. To deploy a workflow, click Deploy in the upper-right corner of Node-RED Editor.
      BMC Helix Edge deploys your workflow, making it active and ready to run.
    7. (Optional) To monitor and test the workflow, use the Node-RED debug panel to monitor the output and behavior of your workflow.
    8. Click Save.
      After the deployment, ongoing monitoring and maintenance are essential to make sure the workflow operates effectively. This monitoring might involve periodic updates, adjustments to accommodate changing conditions, and performance optimization.

Generating service requests by using Node-RED   

  1. On the BMC Helix Edge page, select Rules and workflows > Workflow Builder.
  2. Under Note in the Workflow builder page, select a node to build a workflow.
  3. In the Streams pane, select a data stream for a node, and in the workflow space, perform the following steps:
    1. To add an input node:
      1. Drag and drop an input node from the left sidebar onto the workspace.
      2. Configure this input node to receive the event data related to the oil level.
        For example, you might use an MQTT input node to subscribe to a specific MQTT topic where BMC Helix Edge publishes the oil-level data.
    2. To add rule node:
      1. Drag and drop a function or switch node to your workspace.
      2. Configure this node to check whether the received oil level data is below the threshold.
        You must write a JavaScript function that evaluates the data and decides whether it triggers the rule.
    3. To add output node:
      1. Drag and drop an output node onto the workspace.
      2. Configure this output node to create a work order when the rule is met.
        Depending on your setup, this action might involve making an HTTP POST request to a service that handles work orders or using a custom node if available.
    4. To connect nodes:
      1. Connect the nodes in your workflow by drawing lines between them.
      2. Connect the output of the rule node to the output node's input to establish the data flow.
    5. Configure the output node to create a work order with the necessary details when the rule is satisfied.
      This step depends on the specific system or service you are integrating.
    6. To deploy the workflow, click Deploy to save and activate your workflow.
      When the oil level drops below the defined threshold, the workflow triggers the creation of a work order to replenish the oil automatically. Make sure to customize the nodes, rules, and actions to match your actual setup and requirements.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*