Bosch IoT Insights

Creating a conditional action

Prerequisites

You are assigned to the Power User role or higher.

Proceed as follows

  1. Click the Add Conditional Action button.
    → The configuration page is displayed.

    images/confluence/download/attachments/1624716888/services_conditional_action_create_2023_05_25-version-1-modificationdate-1687420250000-api-v2.png
  2. In the General Information pane, enter a name for the conditional action in the Name field.

  3. Use the Active checkbox to specify whether the conditional action is active or inactive.

  4. In the Description field, enter a description for the conditional action.

  5. In the Retention Time of resulting Log Entries in days field, define the time in days of how long the log entries remain in the conditional actions log.

  6. Activate the Discard payload in activity log (only if action was successful) checkbox to remove the payload in the activity log if the action was successful.

  7. In the Actions pane, activate one or more checkboxes of the actions that shall be executed with the conditional action.

    • REST-Request
      A REST request action can address all available URIs. Depending on the environment onto which you have booked your service instance of Bosch IoT Insights, there can be whitelabeling, proxy, and firewall restrictions.

      images/confluence/download/attachments/1624716888/services_conditional_action_rest_request_2021_03_22-version-4-modificationdate-1667557521000-api-v2.png


      1. In the Resource pane, select an HTTP method in the HTTP-Method drop-down list.

      2. In the Resource Uri field, enter the URI.

      3. In the Authorization pane, select the type of authorization in the Type drop-down list.

      4. Click the Set Configuration button to set up the selected authorization.

        • For Basic Auth:

          1. In the Username field, enter the username.

          2. In the Password field, enter the password.

        • For OAuth 2.0

          1. In the Grant Type drop-down list, select the type of credentials.

          2. Enter the Access Token URL.

          3. Enter the Client ID.

          4. Enter the Client Secret.

          5. If you selected Password Credentials as Grant Type, also enter the Username and the Password .

      5. In the Headers pane, click the Add Header button in the Headers pane and enter the header name and a value.

        The header information depends your target system needs.

      6. In the Body pane, define the HTTP body.

        • Raw Data: Create a Freemarker template that modifies the processed data document in a defined manner, refer to Freemarker Language Reference.

        • Form Data: Follows the HTTP Standard structure which provides key-value pairs.

        • Document: Sends the matched document to the HTTP endpoint.

      7. In the Number field of the Retry Count pane, specify the number of retries the REST request will be repeated until a success HTTP status is responded.

      8. Click the Test button to test the action.

    • E-Mail
      If the conditional action is triggered, an e-mail will be sent to notify the listed users.

      images/confluence/download/attachments/1624716888/services_conditional_action_email_2021_07_01-version-1-modificationdate-1626167223000-api-v2.png


      1. In the Email Recipient field, enter the e-mail address of the user you want to notify.

      2. To add another recipient, press Enter and enter the email address.

        To remove a user from the list, click the x at the end of the email address.

      3. In the Subject field in the Subject pane, enter text that will be displayed in the subject line.

      4. In the Message field, enter the message to be sent.

        You can also provide a placeholder that then shows the value for which the conditional action was triggered. The placeholder expressions are surrounded by ${}. E.g.: ${payload.prop1}.

      5. Click the Test button to test the action.

    • SMS
      If the conditional action is triggered, an SMS will be sent to notify the listed users (this feature might not be visible based on your region).

      images/confluence/download/attachments/1624716888/services_conditional_action_sms_2021_07_01-version-1-modificationdate-1626167223000-api-v2.png
      1. In the SMS Recipient field of the SMS pane, enter the phone number of the user you want to notify.

        The format should be as follows: +49 711 564656767

      2. To add another recipient, press Enter and enter the phone number.

        To remove a user from the list, click the x at the end of the phone number.

      3. In the Message field, enter the message to be sent.

      4. Click the Test button to test the action.

    • Tagging / Labeling
      If the conditional action is triggered, a tag or label will be added to the document.

      images/confluence/download/attachments/1624716888/services_conditional_action_tagging_labeling_2021_03_22-version-2-modificationdate-1626167222000-api-v2.png


      1. In the Key and Value fields, enter a key-value pair.

      2. Click the Add Tag / Label button to add another row.

  8. In the Condition pane, define the condition of the conditional action.

    1. In the Choose a condition type drop-down list, select ProcessedData.

    2. In the Collection drop-down list, select the collection.

    3. In the code block below, enter the condition.

      Conditions are defined as MongoDB Find Query.

If you are adding email and SMS as actions, refer to the following hint:

Due to limitations of the FreeMarker templating language, where certain date-like variables in the data model cannot be automatically classified as date, time, or dateTime, FreeMarker needs this information to be provided explicitly by the user.
If a dateTime variable in your data follows the format yyyy-MM-dd'T'HH:mm[:ss[.SSS]]'Z', you need to add ?date, ?time or ?datetime after the placeholder when configuring it in the email or SMS template.

For example, if you have the following document, you need to configure the template placeholders the following way:


{
"deviceId": "vehicle_audi",
"lastUpdated: "2022-10-16T17:10:55.000Z",
}


The vehicle ${payload.deviceId} was last updated at ${payload.lastUpdated?datetime}.

For more information, refer to https://freemarker.apache.org/docs/ref_builtins_date.html.