Trigger Workflow via WebHook

Nected allows you to securely initiate a workflow from your systems using a Webhook URL. This feature enables you to pass custom parameters and retrieve all pertinent information related to the workflow, ensuring seamless integration and efficient data handling.

To trigger a workflow via webhook, follow these steps:

  1. Test and Publish the Workflow: Ensure the workflow you want to trigger is tested and published.

  2. Access the Trigger Node:

    • Go to the Trigger Node and click on it.

    • Navigate to the Settings tab, where you will find the API and WebHook URL information.

  3. Use the WebHook URL:

    • The Settings tab will display the WebHook URL, which contains all the information and behavior of the workflow trigger.

    • Use the URL to trigger the workflow via WebHook. Below is the URL:

<https://nected-xx.nected.io/nected/webhook/{env}/workflow/{id}/{version}>

The WebHook URL consists of the following components:

  • Base URL: https://nected-xx.nected.io/nected/webhook

  • env: The environment of the rule, either staging or production.

  • entity_name: The name of the rule to be executed.

  • id: The ID of the rule.

  • Version: The version is optional, and will only appear if the rule environment if production.

Inside the 'How to Trigger?' section you'll get this type of cURL code, which you can copy and use seamlessly:

curl -X "POST" "https://nected-xx.nected.io/nected/webhook/production/workflow/65df54bb85d91df40fxxxxx" \
     -H 'Content-Type: application/json' \
     -d $'{
  "Transaction_amt": 10000,
  "aoi": 100000,
  "customer_id": "customer1",
  "date": "21/02/2024",
  "n_list": [
    "ABC",
    [
      2000,
      "Nected",
      "2024-07-02"
    ],
    "2024-07-02T05:47:10Z",
    {
      "key_name_1": "Rule Engine",
      "key_name_2": true
    },
    true
  ],
  "sensor_id": "Prod12"
}'

Well, as we've multi-environment along with multiple versions, it can be confusing for you while working with the API. To minimize your confusion, here is a table clarifying the API behavior based on versions and different environments:

Version
Environment
View
Explanation

"version":"version_value",

"environment":"env_value", (staging/production)

If in your webhook URL, both are written, then simply that specific version of workflow will be executed

"version":"version_value", "environment":"production",

While calling the webhook, in the url, if you've not specified the env but you've specified the version then the default env i.e. production environment of that version will be executed

"version":"latest", "environment":"env_value", (staging/production)

So, if you've not specified the version but the env then the webhook will execute the latest version of the rule of the environment that you've specified i.e. either staging or production.

"version":"latest", "environment":"production",

If you've not specified anything in your webhook url, then by default the latest live/production version of the rule will be called and executed.

This is how the webhook works, so if you're triggering the workflow via WebHook, make sure you follow this and call the webhook accordingly.

As it can be visible, the base URL changed for staging and production like this:

  1. Staging: https://nected-XX.nected.io/nected/webhook/staging/workflow/{id}

  2. Production: https://nected-XX.nected.io/nected/webhook/production/workflow/{id}/0.30

Now, if you've multiple versions, and you want to trigger a specific version of the workflow via webhook, then you can follow this:

  1. Go to the Version Control tab, and click on the "Preview" button for a specific version.

  2. A new tab will be opened for that specific version. Then follow the same steps to go to the Webhook settings.

  3. Then finally copy the URL and other fields.

Passing Custom Attributes Using Webhook

  • After Selecting the Webhook URL, you can use the webhook to pass the information as a custom attribute.

  • To pass custom attributes in Workflow via using WebHook, You can use this flattened payload structure like this:

    {
      "Transaction_amt": 10000,
      "aoi": 100000,
      "customer_id": "customer1",
      "date": "21/02/2024",
      "n_list": [
        "ABC",
        [
          2000,
          "Nected",
          "2024-07-02"
        ],
        "2024-07-02T05:47:10Z",
        {
          "key_name_1": "Rule Engine",
          "key_name_2": true
        },
        true
      ],
      "sensor_id": "Prod12"
    }
  • Once You pass the payload, the webhook will not wait for the workflow execution it runs asynchronously backend. after its successful execution, it responds via a successful message.

Webhook Authentication:

In case you want to authorize your trigger webhook for the rule, you simply follow these steps to do so:

1

Turn on the authentication

Open the API settings, where the first is of Authentication. By default it will be "None". Just open the dropdown, and select "Private". This will turn on the authentication, and now the webhook will need the authorization key to be able to work. You can see that a new line i.e.

-H 'nected-api-key: XXXX-XXXX-XXXX-XXXX'\

is now added in the header.

2

Copy the Nected API key

Now, go to the Authorization page. And simply copy the nected-api-key, like this:

3

Testing the Webhook

In case you're testing the Webhook on Postman, here is what you can do to test the API properly:

First click on Authorization, and then from the auth type dropdown, select API key. Then add key-value and select Header from the "Add to" dropdown.

For Webhook triggers, we currently support the POST method only.

Last updated