This demo application shows how to implement instant lead alerts using Node.js and Express. Notify sales reps or agents right away when a new lead comes in for a real estate listing or other high value channel.
To run this project on your computer, you will need to download and install either Node.js or io.js, both of which should also install npm. You will also need to sign up for a Twilio account if you don't have one already.
-
First clone this repository and
cd
into it.$ git clone [email protected]:TwilioDevEd/lead-alerts-node.git $ cd lead-alerts-node
-
Next, open
.env
at the root of the project and update it with values from your Twilio account and local configuration. You'll need to setTWILIO_AUTH_TOKEN
,TWILIO_ACCOUNT_SID
, andTWILIO_NUMBER
.
For the TWILIO_NUMBER
variable you'll need to provision a new number
in the
Manage Numbers page
under your account.
The AGENT_NUMBER
variable represents the number alerts will be sent to. Please make sure you have allowed SMS to be sent to the Country this number belongs to on the Global SMS Permissions page. Also, if you are on a trial account, make sure you have verified this number on the Verified Callers IDs page.
The phone numbers should be in E.164 format.
Run source .env
to export the environment variables.
- Navigate to the project directory in your terminal and run:
$ npm install
This should install all of our project dependencies from npm into a local node_modules
folder.
- 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 .
-
Install Docker and docker-compose.
-
Make sure you performed step 2 on the previous section.
-
Copy the template .env file and set the required environment variables.You can find these values at https://www.twilio.com/user/account/voice and at https://dashboard.authy.com.
cp .env.example .env
-
Load the variables in your session:
source .env
-
Finally, run the following commands to start your Docker containers:
$ docker-compose up -d
Warning: If you previously ran npm install
locally, the node_modules folder will conflict with the file structure of the container when you run the above command. We recommended installing your node dependencies one folder up from the rest of your source code.
-
You can then visit the application at http://localhost:3000/. If you're using boot2docker to run Docker on OS X, you'll need to use the value of
boot2docker ip
instead oflocalhost
. -
To stop your containers, run
docker-compose stop
.
You can then visit the application at http://localhost:3000/.
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.