This small node.js application intends to show a simple way of performing an action when an AT&T M2X Data Source Trigger is fired, in this case sending an email through the SendGrid API. In order to make setup easier we're assuming you will use Heroku to deploy the application, although you can using any compatible application hosting service.
- Clone this repo and set constants for the notification emails (
EMAIL_FROMandEMAIL_RCPT) inmain.js - Signup/Login to Heroku, create a new application and push code to Heroku
- Add the SendGrid Add-on to the newly created Heroku application
- You can check the status by going into the
/statuspath, of your published application URL.
- Signup for an AT&T M2X Account.
- Create your first Device
- Add Stream(s) to your Device
- Add a Trigger to your Device and point the callback URL to the domain where your application will be hosted (Heroku will provide you with this URL). By default, the URL path will be
/email-trigger, so an example URL would be: http://your-domain.com/email-trigger - Start pushing values to your Device Stream(s).
Please consult the AT&T M2X glossary if you have questions about any M2X specific terms.
Once everything is setup and values are being pushed to your Stream(s), every time a value(s) meets the Trigger condition the API will send a POSTrequest to your application at the URL provided. The application will then process the request and send an email to/from the addresses specified in the code in the EMAIL_FROM and EMAIL_RCPT variables.
This application is delivered under the MIT license. See LICENSE for the specific terms.