/lead-alerts-flask

Instant lead alerts example implemented with Python and Flask

Primary LanguagePythonMIT LicenseMIT

Twilio

Instant Lead Alerts implemented with Python and Flask

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 Python and Flask. 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 Node PHP Ruby
Done Done Done Done Done

Set up

Requirements

  • Python 3.6, 3.7 or 3.8 version.

In some environments when both version 2 and 3 are installed, you may substitute the Python executables below with python3 and pip3 unless you use a version manager such as pyenv.

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 git@github.com:TwilioDevEd/lead-alerts-flask.git
    cd lead-alerts-flask
  2. Create the virtual environment, load it and install the dependencies.

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

    cp .env.example .env

    See Twilio Account Settings to locate the necessary environment variables.

  4. Start the server.

    make serve
  5. Check it out at: http://localhost:5000/.

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:

python3 manage.py 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.