Integrations / Connection guides / The Things Network

The Things Network / The Things Industries

The Things Network and the Things Industries are both using the Things Stack, so in both cases this connection guide works. Just make sure you have the right prerequisites. The Things Stack provides an open-source network where LoRaWAN devices can be connected. The Blockbax Platform provides a native integration with The Things Network, such that your devices can publish measurements to your Blockbax project.


The goal is to configure a device via The Things Network to publish measurements to Blockbax.

  1. Blockbax project
  2. The Things Network account or The Things Industries account
Steps to connect a device
  1. Add your device. Note: Make sure you have configured the necessary subject type in your Blockbax project. Additionally, you can choose to manually create subjects with external IDs matching the device IDs or set the autoCreateSubjects option in the ‘payload formatter’ below to true.

  2. In the left menu of your application select ‘Payload Formatters’

  3. From the dropdown menu select ‘Uplink’

  4. Select Formatter type ‘Javascript’

  5. In the ‘formatter parameter’ you will see a code editor with the function ‘decodeUplink’ already present

  6. Change the contents of the decodeUplink function to the one in the template shown.

  7. Make sure the external IDs in the code editor match the ones from the subject type in your Blockbax project

  8. Add a ‘decoder’ function to unravel your device’s byte payload and return a JavaScript object containing the numeric properties you want to send. This function can be added in the same code editor block as shown in the template below

    function decodeUplink(input) {
      decoded = decoder(input.bytes)
      return {
        data : {
          options: {
            // Set this option to true to create subjects automatically
            autoCreateSubjects: false
          // For numeric metrics
          <BLOCKBAX_EXTERNAL_METRIC_ID>: decoded.exampleNumber,
          // For location metrics
              lat: decoded.exampleLatitude,
              lon: decoded.exampleLongitude
    function decoder(bytes) {
      // Add the logic that decodes the bytes from your device.
      return decodedBytes
  9. Now we will setup the HTTP integration. In the left menu select ‘Integrations’.

  10. Click on ‘Webhooks’

  11. Click on ‘Add Webhook’:

  12. Select the option ‘Custom Webhook’

  13. Enter the information according to the table below

    Field Value
    Webhook Id Your own identifier
    Webhook Format JSON
    Base URL<YOUR_PROJECT_ID>/integrations/53c06128-ce26-4dcc-8d74-5c45b302b525/measurements Note: Your project ID can be found in the URL when you open your project in the web app, e.g.
    Downlink API Key Your The Things Network access key used for downlink
    Additional Headers Add a header entry with name Authorization and value ApiKey <ACCESS_TOKEN_SECRET> Note: Your ACCESS_TOKEN_SECRET is the secret of your access token.
  14. Make sure to tick the ‘Enabled’ checkbox at ‘Enabled Messages’. A textbox will be visible after checking this box, make sure to leave this textbox empty

Once you’ve added the integration, check your Blockbax project to see the measurements coming in.