Webhook
Last updated
Last updated
A private webhook plugin is a user-defined logic whose executions is triggered by making an HTTP request to its HTTPS Endpoint URL:
As stated before any Private plugin regardless of its type, and, particularly, a private webhook plugin, is composed by the file structure shown below:
This is a script, written either in Python or NodeJS. This can be thought as a "setup" script since it will run only once at the moment of creating the plugin.
This is written in either Python or NodeJS, and it holds the plugin's core logic. The script runs every time an HTTP request is made to the plugin's HTTPS Endpoint URL.
This is written either in Python or NodeJS.
If required, the plugin's developer can opt to offer its users a way to execute custom logic. Thus, this script empowers the user with an additional level of customization.
For instance, if a developer creates a webhook plugin to fetch data from an external API, they might want to allow users to further process or redirect that data without altering the core logic.
The user_code
script provides this flexibility, maintaining the plugin's encapsulation while offering a dedicated space for user-specific logic.
You ought to retain the names of all files and directories mentioned in the "required files" section, as the plugins engine specifically searches for these files and their extensions.
For instance:
If your plugin is using Python as runtime, the scripts' names should be control.py
, function.py
and user_code.py
If your plugin is using NodeJS as runtime, the scripts' names should be control.js
, function.js
and user_code.js
The language selected for the control
, function
and user_code
scripts must match with the value of theruntime
key in the manifest.toml file
This file provides the developer with the capability of building and displaying a form, so the plugin's users can use it to input the required parameters by it
The contents of this form are displayed when the plugin is about to be created.
For instance, if creating a plugin to receive data from an LNS during device uplinks, you'd need the user's LNS and Ubidots credentials. A GUI for this widget might look like:
This can be achieved using text fields in the form as shown below:
All of these parameters in the form are accessible to the function
, control
and user_code
scripts on each of its executions within the _parameters
key in the incoming JSON object.
For detailed information about the supported form elements, please head to the view.xml section in the Plugins development page:
Refer to Private Plugins page to get more information:
Private PluginsAside from the manifest components common to all plugin types, the following ones are specific to Webhook type plugin:
Section | key | Value | Description | Example |
---|---|---|---|---|
[settings] | runtime | Any valir Python or NodeJS version | Environment in which the plugin will run |
|
[settings.webhook] | default_http_method | A valid HTTP method | Default HTTP method to be used by the plugin |
|
[settings.webhook] | allowed_http_methods | A list of valid HTTP methods | HTTP methods allowed by the plugin |
|
With that in mind, a typical manifest.toml file for a Private Webhook plugin looks like:
All of these manifest's keys are mandatory