Trigger Rule via WebHook
Last updated
Last updated
Nected helps you to seamlessly automate and trigger rules and workflows directly from your systems via WebHooks. By leveraging WebHooks, you can integrate custom parameters and ensure real-time execution of predefined rules and workflows. Additionally, easily integrate third-party services and applications to further extend the capabilities of the Nected platform. Follow the steps below to maximize the benefits of WebHooks within your automated workflows and rules.
Nected enables you to securely trigger a rule from your systems via WebHook, allowing you to use custom parameters and access all relevant information about the rule.
To trigger a rule using a WebHook, follow these steps:
Test and Publish the Rule: Ensure the rule you want to trigger is tested and published.
Access the Trigger Settings:
Go to the Trigger section of the rule.
Update the rule trigger settings as needed.
From the toggle option click on WebHook. And then copy the Webhook URL. To edit the webhook, click on the gear icon after the base URL field.
After that, the API Settings window will appear, like this:
In the settings window, again click on the toggle button to change the settings from API to WebHook as shown in the GIF. And then copy the required field as per your need.
Use the WebHook URL: The API Settings window contains the WebHook URL, which includes all the information and behavior of the rule. Use this URL to trigger the rule via WebHook.
WebHook URL Template: The Webhook URL looks like this:
Where the 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
.
id: The ID of the rule.
version: The version is optional, and will only appear if the rule environment if production.
nected-api-key: You'll see this in your cURL code if you've enabled authentication for your rule.
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":"version_value",
"environment":"env_value", (staging/production)
If in your webhook URL, both are written, then simply that specific version of rule 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 by default the production
environment will be called of that version.
❌
✅
"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 rule via WebHook, make sure you follow this and call the webhook accordingly.
Here is the difference between the triggering rule via Webhook for the draft rule and the publishing respectively:
As it can be visible, the base URL changed for staging and production like this:
Staging: https://nected-XX.nected.io/nected/webhook/staging/rule/{id}
Production: https://nected-XX.nected.io/nected/webhook/production/rule/{id}/0.30
Now, if you've multiple versions, and you want to trigger a specific version of the rule via webhook, then you can follow this:
Go to the Version Control tab, and click on the "Preview" button for a specific version.
A new tab will be opened for that specific version. Then follow the same steps to go to the Webhook settings.
Then finally copy the URL and other fields.
You can pass custom attributes to a rule using the WebHook by utilizing a flattened payload structure. Here’s how to do it:
Select the WebHook URL: Once you have the WebHook URL, you can use it to pass custom attributes.
Payload Structure: Unlike the API, the payload structure for webhooks is different. Here we use flattened JSON like this:
Execution: The WebHook will run asynchronously in the backend. After successful execution, it will respond with a success message.
By following these steps, you can effectively trigger and manage rules within the Nected platform using WebHooks.