TwilioDevEd / marketing-notifications-node

Demo application showing how to implement SMS notifications (for a mobile marketing use case) in Node.js

Home Page:https://www.twilio.com/docs/tutorials/walkthrough/marketing-notifications/node/express

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Twilio

SMS Notifications for Node.js and Express

Node.js CI

This example project demonstrates how to send SMS notifications (for a mobile marketing campaign) using Node.js and Express.

Read the full tutorial here!

Running the Project in production

1. Deploy your App

2. Configure your Twilio number

Go to your dashboard on Twilio. Click on Twilio Numbers and choose a number to setup.

On the phone number page, enter https://<appname.com>/message into the Messaging Request URL field.

Learn how to configure a Twilio phone number for Programmable SMS

3. Wrap Up!

Now your subscribers will be able to text your new Twilio number to 'Subscribe' to your Marketing Notifications line.

Congratulations!

Running the Project on Your Machine

To run this project on your computer, download or clone the source. You will also need to download and install:

Finally you will also need to sign up for a Twilio account if you don't have one already.

1. Install Dependencies

Navigate to the project directory in your terminal

npm install

This should install all of our project dependencies from npm into a local node_modules folder.

2. Copy the sample configuration file and edit it to match your configuration

cp .env.example .env

3. Configuration

Next, open config.js at the root of the project and update it with values from your environment and your Twilio account. You can either export these values as system environment variables (this is the default setup), or you can replace these values with hard-coded strings (be careful you don't commit them to git!).

This sample application stores data in a MongoDB database using Mongoose.

You can download and run MongoDB yourself

Our application will be looking for a fully qualified MongoDB connection string with a username and password embedded in it.

4. Running the Project

To launch the application, you can use node . in the project's root directory. You might also consider using nodemon for this. It works just like the node command, but automatically restarts your application when you change any source code files.

npm install -g nodemon \
nodemon .

5. Exposing Webhooks to Twilio

You will likely need to expose your local Node.js web application on the public Internet to work with Twilio. We recommend using ngrok to accomplish this. Use ngrok to expose a local port and get a publicly accessible URL you can use to accept incoming calls or texts to your Twilio numbers.

The following example would expose your local Node application running on port 3000 at http://chunky-danger-monkey.ngrok.com (reserved subdomains are a paid feature of ngrok):

ngrok -subdomain=chunky-danger-monkey 3000

License

MIT

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.

About

Demo application showing how to implement SMS notifications (for a mobile marketing use case) in Node.js

https://www.twilio.com/docs/tutorials/walkthrough/marketing-notifications/node/express

License:MIT License


Languages

Language:HTML 63.2%Language:JavaScript 29.3%Language:Pug 6.5%Language:CSS 0.7%Language:Shell 0.3%Language:Procfile 0.0%