Code Monkey home page Code Monkey logo

pa-messenger's Introduction

PA Messenger

A simple flask app to help run a text loop

Use Twilio to create SMS notifications to keep your subscribers in the loop.

Local Development

  1. You will need to configure Twilio to send requests to your application when SMS are received.

    You will need to provision at least one Twilio number with SMS capabilities so the application's users can join the loop. You can buy a number right here. Once you have a number you need to configure your number to work with your application. Open the number management page and open a number's configuration by clicking on it.

    Remember that the number where you change the SMS webhook must be the same one you set on the TwilioPhoneNumber setting.

    Keep in mind that our endpoint is:

    http://<your-url>/message
    
  2. Clone this repository and cd into it.

    git clone [email protected]:polymerwitch/pa_messenger.git
    
  3. Create a new virtual environment.

    python3 -m venv venv
    source venv/bin/activate
    
  4. Install the requirements using pip.

    pip install -r requirements.txt
    
  5. Edit the config file (pa_messenger.cfg) inside the root of the project, and be sure to replace the place holders and connection string with real information.

SECRET_KEY = 'your_authy_secret_key'

TWILIO_ACCOUNT_SID = '[your_twilio_account_sid]' TWILIO_AUTH_TOKEN = '[your_twilio_auth_token]' TWILIO_NUMBER = '[your_twilio_phone_number]'

SQLALCHEMY_DATABASE_URI = 'sqlite://' ```

  1. Run the migrations.

    python manage.py db upgrade
    
  2. Start the development server.

    python manage.py runserver
    

That's it!

Run the tests

You can run the tests locally through coverage:

  1. Run the tests.

    $ coverage run test.py
    

You can then view the results with coverage report or build an HTML report with coverage html.

Deploy to Heroku

For smaller loops you can run this on a free dyno from heroku

  1. Get the Heroku cli Heroku-Cli

  2. cd into the cloned project directory

    $ cd pa_messenger
    
  3. Login to Heroku

    $ heroku login
    
  4. Create the heroku app

    $ heroku create my_text_app
    
  5. Ensure pa_messenger.cfg is configured as outlined above and commit the changes. The database url can be gotten with:

    $ heroku config
    
  6. Set heroku to be production

    $ heroku config:set ENV=production
    
  7. Set heroku to read the config file

    $ heroku config:set PA_MESSENGER_CONFIG=../pa_messenger.cfg
    
  8. Push the app to Heroku

    $ git push heroku master
    
  9. Scale the dyno

    $ heroku ps:scale web=1
    
  10. Setup the DB

    $ heroku run python manage.py db upgrade
    $ heroku run python manage.py db migrate
    
  11. You should be set!

Meta

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

pa-messenger's People

Contributors

0xbeeb avatar

Watchers

 avatar

Forkers

chasetawilson

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.