Skip to main content

Webhook

The Webhook Integration allows you to receive notification callbacks triggered by updates within your myDevices data, alerts and information.

Note: This integration provides both sensor (uplink), gateway(keepalive), and alert events.

  • Creating a new Webhook
  • Verifying things are working
  • Example payloads

Creating a new Webhook

Use the following steps to setup your new webhook on the myDevices side.

  1. Log into your account on the myDevices portal or using the mobile app.
  2. Select the Integrations option and then select the Webhook integration.
  3. Enter the following information to complete the integration:
    • Name: Enter a name for this integration. In case you have multiple integrations, this will help uniquely identify it in the list.
    • Url: Enter the URL that you would like to be called in response to myDevices updates.
    • Headers (optional): Enter headers values in query string format, for example:
      X-Api: secret-key
      Authorization: Token
      will need to be input like this: x-api=my-secret-key&authorization=Token

After saving the Integration, you will see it shown in your list of integrations.

  • You can then edit the integration to make any changes needed.
  • You can also toggle the Integration on/off at any time from here as well. Disabling the integration will stop new data from being sent to the webhook.

Payload Transformation

The payload transformation is a JavaScript script that can be used to re-structure the outgoing Webhook data.

info

When writing JavaScript code, keep in mind that the JavaScript interpreter does not support modern ECMAScript features. This includes ES6+ syntax such as shorthand object properties, arrow functions, let/const declarations, template literals, and array methods with newer syntax.

// Transform webhook payload to non-standard format
// - 'event' contains the standard JSON schema
// - 'metadata' contains fuseData/metadata such as company and location.
// The function Transform must return an object, e.g. {"temperature": 22.5}
function Transform(event, metadata) {
var body = {};

event.payload.forEach(function(item) {
body[item.name] = item.value;
});

// { "temp": 23, "hum": 75, "rssi": -110 }
return body;
}

Verifying things are working

You can verify the integration is working by waiting for a sensor reading (or manually triggering on the device or within the dashboard). As soon as a new event occurs, the webhook will be notified and include the event payload.

You can also use a temporary service, such as Webhook.site to get a sense of how things work before integrating payload events into your service.

JSON Schema

Example Payloads

Uplink Event:

Alert Event: