A webhook is a method of augmenting or altering the behavior of a web page, or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application.
To setup an Ubidots Webhook go the the Event tab into your Ubidots account:
Then create a new event selecting "+ Add event" to setup the Webhook:
Select the Variable that will trigger the event once the condition(s) is(are) met.
Ubidots lets you setup the conditions of the Event in three ways:
Value, Has been Inactive, or Location:
Upon completing the condition setup, head to the next step, Actions, and select the WebHook option to interact with a 3rd party web services:
Now, just need to setup the Webhook based on the 3rd party web service recipient API.
The parameters required in the setup of a WebHook are:
URL: This is the server endpoint that will receive the webhook payload
Method: This is the HTTP method of the request made upon the event trigger. Allow methods are GET, HEAD, DELETE, POST, PUT and PATCH.
Headers: headers of the request. This may include the Content-Type or the Authentication of the request.
In the right panel, you then need to build your message based on the expected format of the 3rd party service. Most commonly, web services expect JSON payload, but URL Encoded or others specific data frames my apply as well.
Use the bookmark variables to fill your payload with the information of the device, variable or value that trigger the events
You can set the BACK TO NORMAL payload as well, which will send another webhook once the variable that trigger the events comes back to usual values outside the triggering condition.
Also, in this panel, you can set up the "Repeat action" option, that will send consecutive webhooks in a time period basis while the event condition is still active. up to a maximum of 50 repetitions.
IMPORTANT NOTE: Often, 3rd party web services implement firewall restrictions of which external services, such as Ubidots, can access their resources through webhooks. In those cases, it is necessary to add the external service IP address to the recipient firewall rules to avoid webhook request rejection. The following is Ubidots' pool of IPs used to generate the webhooks, so make sure, if needed, to add it to the respective firewall rules.