Sample Webhooks Handler
This is a small sample webhooks handler for a MODE project.
If you don't know how webhooks for MODE work, please refer to this doc.
How to Run on Heroku
You can launch this sample webhooks handler on Heroku by following these steps:
- Create an account on Heroku, if you don't have one already.
- Go to the MODE Developer Console and set up a new Webhooks Smart Module for your project.
- Set up an Event Webhook for the Smart Module using an URL in the format
HEROKU_APP_NAMEshould be replaced by a unique app name in the Heroku namespace.
- Click this button -->
- You will land on the Heroku screen for deploying a new app. Make sure you enter the Heroku app name you used in step 3. You must also enter the appropriate values for the config variables
EVENT_KEY(event webhook key) and
EVENT_URL(event webhook URL). You can get these from the Smart Module settings page on the MODE console.
- Deploy the Heroku app.
After launching the Heroku app, open the app's URL on your browser. You will see the message:
No device event. It means the code is running. Now, you can send an event from a device, or from the Device Simulator. If
EVENT_URL are correctly set, you should see the event JSON string appearing on the browser screen, which looks like this: