A webhook is a method of broadening or altering the behavior of a website or 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.
1. Create a new event
To begin, head to the “data” tab →"Events" and hover over the “+” button, located at the upper right corner of the screen, and create a conditional event, global event, or scheduled event depending on your needs.
Next, configure the event’s logic using triggers with an AND/OR logic. For additional details on how to configure these triggers, head to their corresponding guides: value based, inactivity, geofence.
2. Configure the webhook action
With the "trigger" logic configured, it’s now time to set up the webhook action.
1. Click on the “+ add action” button to start the process. From the available options, choose “trigger webhook”.
2. Choose the HTTP method. This is the HTTP method of the request made upon the event trigger.
Allowed methods are GET, HEAD, DELETE, POST, PUT, and PATCH.
3. Enter the URL. This is the server endpoint that will receive the webhook payload.
4. Define the headers of the request. These may include the content-type or the authentication. Multiple headers can be added.
5. Customize the “active trigger” and the “back to normal” (optional) messages. Most commonly, web services expect JSON payload, but URL encoded (or other specific data frames) may apply as well.
By using the tag icon at the upper right corners of the “subject” and “message” fields you can easily add information such as device ID, timestamp, variable name, etc.
Note: By default, data inputs involving timestamps are sent in human-readable format (YYY-MM-DD HH:mm:ss TZ). If you'd rather attach UNIX epoch time in milliseconds, double-click on the data input and delete the text from the pipe symbol ("|") until the end, as shown below.
6. Optionally, enable the “repeat action” option if you want to repeat the action multiple times while the event is triggered. You can choose how often and up to how many times the action will be repeated. There’s a limit of 50 action repetitions.
7. Click on “save” once you finish configuring the action and on “next”, unless you want to set up multiple actions.
8. After completing the action configuration you’ll proceed to the final step, the “settings” tab. There, you’ll name the event and give it a description (optional).
9. Another optional step is to use a tag on the event. This is a great tool to control what your end users see in your app. In this case, for instance, you could decide that your end user sees one event, but not another, using tags. Learn more about tags here.
10. Finally (unless the event you created is a scheduled event), determine the activity window in which the events should be executed. An event can have multiple active windows by clicking on the “+ add window button” and configuring them correspondingly. After finishing this, click on “save” and your event will be deployed.
IMPORTANT NOTE: Often, third-party web services implement firewall restrictions that may prevent external services like Ubidots from accessing their resources through webhooks. In those cases, it’s necessary to add the external service’s IP address to the recipient firewall rules to avoid webhook request rejection. Here is Ubidots' pool of IPs used for webhooks. If needed, make sure to add them to the respective firewall rules:
158.85.89.43
169.48.10.57