Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

TwilioDevEd/lead-alerts-node

Repository files navigation

Twilio

Instant Lead Alerts for Node.js and Express

This template is part of Twilio CodeExchange. If you encounter any issues with this code, please open an issue at github.com/twilio-labs/code-exchange/issues.

About

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.

Read the full tutorial here!

Implementations in other languages:

.NET Java Python PHP Ruby
Done Done Done Done Done

Set up

Requirements

Twilio Account Settings

This application should give you a ready-made starting point for writing your own application. Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
TWILIO_ACCOUNT_SID / TWILIO_AUTH_TOKEN You could find them in your Twilio Account Settings
TWILIO_NUMBER You may find it here
AGENT_NUMBER This 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

Local development

  1. First clone this repository and cd into it.

    git clone [email protected]:TwilioDevEd/lead-alerts-node.git
    cd lead-alerts-node
  2. Install the dependencies.

    npm install

    See Twilio Account Settings to locate the necessary environment variables. The phone numbers should be in E.164 format.

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

    cp .env.example .env
  4. Start the server, will run on port 3000.

    npm start

    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. Navigate to http://localhost:3000

That's it!

Docker

If you have Docker already installed on your machine, you can use our docker-compose.yml to setup your project.

  1. Make sure you have the project cloned.
  2. Setup the .env file as outlined in the Local Development steps.
  3. Run docker-compose up.

Tests

To execute tests, run the following command in the project directory:

npm test

Cloud deployment

Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.

Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.

Service
Heroku Deploy

Resources

  • The CodeExchange repository can be found here.

Contributing

This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.