Skip to content

TwilioDevEd/receive-mms-django

Repository files navigation

Twilio

Recieve and Download Images on incoming MMS Messages. Powered by Twilio - Python/Django

Use Twilio to receive SMS and MMS messages. For a step-by-step tutorial see the Twilio docs.

Note: protect your webhooks

Twilio supports HTTP Basic and Digest Authentication. Authentication allows you to password protect your TwiML URLs on your web server so that only you and Twilio can access them.

Learn more about HTTP authentication here, which includes sample code you can use to secure your web application by validating incoming Twilio requests.

Local development

This project is built using the Django web framework. It runs on Python 2.7+ and Python 3.4+.

To run the app locally:

  1. Clone this repository and cd into it

    git clone git@github.com:TwilioDevEd/receive-mms-django.git
    cd receive-mms-django
  2. Create a new virtual environment using virtualenv

    virtualenv -p python3 venv
    source venv/bin/activate
  3. Install the requirements

    pip install -r requirements.txt
  4. Copy the sample configuration file and edit it to match your configuration

    cp .env.example .env

    You can find your TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN in your Twilio Account Settings. You will also need a TWILIO_PHONE_NUMBER, which you may find here.

    Note: To run using production environment use cp .env.production.example .env and follow previous steps

  5. Load your environment configurations into your shell session

    source .env
  6. Run the migrations

    python manage.py migrate
  7. Run the application

    python manage.py runserver
  8. Expose your application to the wider internet using ngrok. This step is important because the application won't work as expected if you run it through localhost.

    ngrok http -host-header=localhost 8000

    Once ngrok is running, open up your browser and go to your ngrok URL. It will look something like this: http://9a159ccf.ngrok.io

    Note: You can read this blog post for more details on how to use ngrok.

  9. Configure Twilio to call your webhooks

    You will also need to configure Twilio to call your application when calls are received on your TWILIO_NUMBER. The MMS url should look something like this:

    http://6b5f6b6d.ngrok.io/incoming/
    

  Configure Webhook

  1. Check it out at http://localhost:8000

That's it

Note: To enable debug logs in local environment, set the DEBUG variable to True in the developemt.py file

How to Demo

  1. Send an MMS to your twilio number

  2. Access http://localhost:8000. You should see a list with all the resources sent through your MMS

Meta

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

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published