Skip to content

lokmien/sample-trigger-app

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

M2X Sample Trigger Application

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.

Setup Application

  1. Clone this repo and set constants for the notification emails (EMAIL_FROM and EMAIL_RCPT) in main.js
  2. Signup/Login to Heroku, create a new application and push code to Heroku
  3. Add the SendGrid Add-on to the newly created Heroku application
  4. You can check the status by going into the /status path, of your published application URL.

Setup Device, Stream(s) and Trigger

  1. Signup for an AT&T M2X Account.
  2. Create your first Device
  3. Add Stream(s) to your Device
  4. 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
  5. Start pushing values to your Device Stream(s).

Please consult the AT&T M2X glossary if you have questions about any M2X specific terms.

Usage

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.

License

This application is delivered under the MIT license. See LICENSE for the specific terms.

About

Example Node.js application showcasing integration with the M2X triggers functionality.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%