Hello everyone,
Recently I’ve been working on a IoT Water Tank level sensor to measure the water level for a small water tower. When the water level gets low the Photon in my project sends out an event and I needed away to push that event to my devices. So that I could easily filter the event I decided to have the event trigger a webhook which would, in turn, send out an email. When I couldn’t find an email webhook I wrote one myself. Tutorial/instructions below. It takes about 10 minutes to get through it.
- Head on over to mailgun and register for an account.
- Login and take a look at your mailgun dashboard.
- You should see an active sandbox domain. You can add your own, custom, domain but that is outside the scope of this tutorial. Click on the link for your sandbox domain.
- You should now see a page with information for your sandbox domain. You want to make sure to write down / save the following two values from this page “API Base URL” and “API Key”.
- Navigate to the Particle Dashboard Integration Page.
- Select “New Integration” and then “Webhook”.
- Click “Custom JSON” in the top right of the page.
- In a new tab grab the contents of this file and paste into the Custom JSON text box on the new Webhook page
- Fill in the all values which are IN_ALL_CAPS as follows
- EVENT_PREFIX - This is your event name or prefix.
- MAILGUN_API_BASE_URL - This is the
API Base URL
from earlier. - MAILGUN_API_KEYKEY - This is the
API Key
from earlier - TO_EMAIL - This is the email you want to send an email to. Example would be "name@email.com"
- ANY_NAME - This is literally anything you want. I call mine “Particle Webhook Bot”
- ANY_EMAIL_ADDRESS - This can again be anything. I use “particle”
- MAILGUN_SANDBOX_DOMAIN - This is your sandbox domain
- ANY_SUBJECT - This is the subject of the email
- ANY_BODY - This is the body of the email
- Click “Create Webhook”.
- Send an event from one of your devices (or the CLI) with an event name which either starts with EVENT_PREFIX or is EVENT_PREFIX
- You should receive an email.
If you have any issues feel free to post here and I’ll try to help!