In this article we will show you how you create a Datacake Webhook Integration for TheThingsNetwork public LoRaWAN Server.
This Integration will allow you to:
Receive Uplinks from your Device
Send Downlinks to your Device
On your TTN-Application navigate into the "Integrations" Tab using the top right Tab-Bar:
Next Click on "add integration" to create a new Integration in your Application:
Clicking will show you a selection of available Integration-Templates.
Here you select the "HTTP Integration" Template:
When selecting this it will show you a new page where you need to provide additional details in order to set up the HTTP Integration:
Enter a basic Name or ID (you can chose freely)
Clicking will show you a list of available Key-Sets. You can chose "default key" which was automatically created in your Application.
Here you paste the following Webhook-URL:
Method should be set do "POST" which it normally is already set to (per default).
One of the cool things of TheThingsNetwork is that by setting the "Access Key" on the Webhook Integration, Datacake recevies all the Information it needs via incoming Webhook to send downlinks.
This is activated by default but we now show you how you can access this and change this in case the Information is not provided automatically or if you want to change that.
First of all move into the configuration menu on one of your Datacake Devices:
Now scroll down until you see the LoRaWAN Section:
The Checkbox "Populate credentials from upstream message" is automatically activated and once the first message was received from your device, the embedded information will be used to fill the downlink settings which are shown underneath the Checkbox:
In case you are interested to configure Downlink Integration manually you simply have to deactivate the "Populate credentials from upstream message" and enter the information manually by using the available fields.
Select the Region of your TTN Network
This is the Device Identification like shown in the following screenshot:
The TTN App-ID is the Application ID of your Application on TheThingsNetwork. You can find it here:
This is the ID of your Datacake-Webhook-Integration you set on TTN. You'll find it:
To access this navigate into the Integrations of your Application and select the Webhook Template you created for Datacake just like described earlier on this page.
You need to provide an access Token so that Datacake can queue Downlinks on your application. You can either create a new one or use the default access key. You find this here:
Navigate into the Overview of you TTN Application
Scroll down to the Bottom
The Tokens are located at the bottom of the overview:
Click on the "Copy"-Icon on right end of the Key-Entry in that list.
This will copy the key to your clipboard.
You can paste this into the LoRaWAN Configuration on your Datacake Device.
If you want you can add extra security to your webhook by creating an API User and adding the Token to your webhook integration on TTN.
This is not required and webhooks are per default a very safe way of sending encrypted Data between networks. However if you want to add extra Security you have to create an API User.
In your Datacake Workspace select "Members" from Sidebar.
Next click on "API Users" on Tab bar to navigate into the API User Section.
Here you click on "Add API User" to create a new API User.
This will show you the following dialog:
Now enter a Name for your API User (Like "TTN Webhook API User")
Select "Devices" from Workspace Permissions
Click on "Add Permissions for all Devices" if you want the Token to be valid for all current and future devices in your workspace.
Use the Text field "Add Device" to search for individual Devices you want to add to that Token (you can change or add this later on Device-View as well).
On "All devices in workspace" or individual device select "Can record measurements" option.
Create the API Token by pressing on "Save".
You will now see the API User appearing in the List
Click on "Show" Button to make Token readable and copy it
Now navigate back into the Integration Settings on your TTN Application
Enter the Token under "Authorization" like this:
Click on Save to apply changes