Heroku
An example integration on forwarding Data Connector events to a server hosted on Heroku.
Last updated
Was this helpful?
An example integration on forwarding Data Connector events to a server hosted on Heroku.
Last updated
Was this helpful?
This example uses a Data Connector to forward the events of all devices in a project to a server hosted on . When receiving the HTTPS POST request, our application will verify both the origin and content of the request using a .
The following points are assumed.
You have the of Project Developer or higher in your DT Studio project.
You are familiar with the and know how to .
You are familiar with the .
Ensure you have the following software installed on your local machine.
, the popular version control tool.
, for interacting with Heroku.
A functioning local environment for the language of your choice.
On your machine, create and enter a new directory for your app.
In the directory, create a new file app.py
where you paste the following snippet which contains the Flask server code for receiving and validating the Data Connector request.
In the same directory, create a new file requirements.txt
with the following contents. Heroku will install these dependencies in its environment before starting the server.
The following steps will deploy your application to a new app in Heroku. Take note of the app name given to the application in step 4.
Initialize your app's directory as a Git repository: git init
Add all changes: git add .
Commit the changes: git commit -m "initial commit"
Create the Heroku app, and add it as a Git remote: heroku create <APP_NAME>
. You can pick a unique app name yourself or let Heroku create a random one by omitting <APP_NAME>
. This will be used as a part of the URL for your server.
Push your application to Heroku: git push heroku main
Add a new signature secret configuration variable to your app using the following command. This can be read by the python instance and imported as an environment variable to use. Use a strong secret.
Your app is now ready to receive requests, but we need to know the endpoint URL. This can be acquired by looking at the Web URL field in the results of the following command. Save it for later.
Endpoint URL: The Web URL found in the previous step.
Signature Secret: The value of DT_SIGNATURE_SECRET environment variable.
If instead the Error counter increments, a response containing a non-2xx status code is returned.
Verify that the Data Connector endpoint URL is correct.
You can view the logs of your Heroku app with the following command.
Finally, specify the command Heroku should run by adding a Procfile
with the following snippet. This instructs Heroku that the server should run a single process of type web
, where should be used to serve the app using a variable called app
in a module called app
(app.py
)
Finally, specify the command Heroku should run by adding a Procfile
with the following snippet. This instructs Heroku that the server should run a single process of type web
, where should be used to serve the app using a variable called app
in a module called app
(app.py
)
To continuously forward the data to our newly created Heroku server, a Data Connector with almost all default settings is sufficient. Refer to if you are unfamiliar with the process. The following configurations should be set.
Depending on your integration, it can also be smart to disable the event types you are not interested in. For instance, the is sent every and will by default be forwarded by the Data Connector if not explicitly unticked.
If the integration was correctly implemented, the Success counter for your Data Connector should increment for each new event forwarded. This happens each or by touching a sensor to force a new event.