Giter Site home page Giter Site logo

twiliodeved / call-tracking-django Goto Github PK

View Code? Open in Web Editor NEW
19.0 22.0 12.0 1.72 MB

Use Twilio to track the effectiveness of your different marketing campaigns.

Home Page: https://www.twilio.com/docs/tutorials/walkthrough/call-tracking/python/django

License: MIT License

Python 78.34% JavaScript 2.45% HTML 17.66% Shell 1.37% Procfile 0.18%
twilio-voice

call-tracking-django's Introduction

Twilio

Call Tracking (Django)

Build and test Coverage Status

Use Twilio to track the effectiveness of your different marketing campaigns. Learn how call tracking helps organizations in these Twilio customer stories.

Read the full tutorial here!

Quickstart

Create a TwiML App

This project is configured to use a TwiML App, which allows us to easily set the voice URLs for all Twilio phone numbers we purchase in this app.

Create a new TwiML app in the Twilio Console and use its Sid as the TWIML_APPLICATION_SID environment variable wherever you run this app.

Learn how to create a TwiML app.

Twilio Account Settings

Config Value Description
Account Sid Your primary Twilio account identifier - find this in the Console.
Auth Token Used to authenticate - just like the above, you'll find this here.
TwiML app Sid TwiML app SID can be found by clicking on your TwiML App in the console

Local development

This project is built using the Django web framework. It runs on Python 3.6+.

To run the app locally, first clone this repository and cd into its directory. Then:

  1. Create a new virtual environment:

  2. Install the requirements:

    pip install -r requirements.txt
    
  3. Start a local PostgreSQL database and create a database called call_tracking:

    • If on a Mac, I recommend Postgres.app. After install, open psql and run CREATE DATABASE call_tracking;
    • If Postgres is already installed locally, you can just run createdb call_tracking from a terminal
  4. Copy the .env.example file to .env, and edit it to include your Twilio API credentials (found at https://www.twilio.com/user/account/voice)

  5. Run source .env to apply the environment variables (or even better, use autoenv)

  6. Run the migrations with:

    python manage.py migrate
    
  7. Optionally create a superuser so you can access the Django admin:

    python manage.py createsuperuser
    
  8. Collect static files from each of your application

    python manage.py collectstatic
    
  9. Start the development server

    python manage.py runserver
    

To actually forward incoming calls, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.

Once you have started ngrok, update your TwiML app's voice URL setting to use your ngrok hostname, so it will look something like this:

http://88b37ada.ngrok.io/call-tracking/forward-call

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

Use Production Environment

Follow previous guide and in step 6 do:

  1. Copy the .env.prod.example file to .env, and edit it to include your Twilio API credentials (found at https://www.twilio.com/user/account/voice)

Run the tests

You can run the tests locally through coverage:

$ coverage run manage.py test --settings=twilio_sample_project.settings.test

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

Meta

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

call-tracking-django's People

Contributors

alexisbcc avatar atbaker avatar dependabot-preview[bot] avatar fefi95 avatar jefflinwood avatar joliveros avatar kwhinnery avatar mcelicalderon avatar sarias-tw avatar satchkat avatar smendes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

call-tracking-django's Issues

New error when setting up on heroku

@atbaker Here is the new error

-----> Python app detected
-----> Installing python-3.6.2
-----> Installing pip
-----> Installing requirements with pip
Collecting Django==1.8 (from -r /tmp/build_7aaf2fe3a538e93211d2215435edf738/TwilioDevEd-call-tracking-django-deba9ef/requirements.txt (line 4))
Downloading Django-1.8-py2.py3-none-any.whl (6.2MB)
Collecting django-bootstrap3==6.1.0 (from -r /tmp/build_7aaf2fe3a538e93211d2215435edf738/TwilioDevEd-call-tracking-django-deba9ef/requirements.txt (line 7))
Downloading django-bootstrap3-6.1.0.tar.gz
Collecting django-forms-bootstrap==3.0.1 (from -r /tmp/build_7aaf2fe3a538e93211d2215435edf738/TwilioDevEd-call-tracking-django-deba9ef/requirements.txt (line 8))
Downloading django-forms-bootstrap-3.0.1.tar.gz
Collecting django-phonenumber-field==0.7.2 (from -r /tmp/build_7aaf2fe3a538e93211d2215435edf738/TwilioDevEd-call-tracking-django-deba9ef/requirements.txt (line 9))
Downloading django-phonenumber-field-0.7.2.tar.gz
Collecting phonenumbers==7.0.8 (from -r /tmp/build_7aaf2fe3a538e93211d2215435edf738/TwilioDevEd-call-tracking-django-deba9ef/requirements.txt (line 10))
Downloading phonenumbers-7.0.8.tar.gz (2.1MB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-gbu5ivfl/phonenumbers/setup.py", line 33, in
from phonenumbers import version
File "/tmp/pip-build-gbu5ivfl/phonenumbers/phonenumbers/init.py", line 132, in
from .phonenumbermatcher import PhoneNumberMatch, PhoneNumberMatcher, Leniency
File "/tmp/pip-build-gbu5ivfl/phonenumbers/phonenumbers/phonenumbermatcher.py", line 161, in
re.compile(u("(?u)(?:\p{Z}-|-\s)\s*(.+)")),
File "/app/.heroku/python/lib/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/app/.heroku/python/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/app/.heroku/python/lib/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/app/.heroku/python/lib/python3.6/sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/app/.heroku/python/lib/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/app/.heroku/python/lib/python3.6/sre_parse.py", line 765, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "/app/.heroku/python/lib/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/app/.heroku/python/lib/python3.6/sre_parse.py", line 502, in _parse
code = _escape(source, this, state)
File "/app/.heroku/python/lib/python3.6/sre_parse.py", line 401, in _escape
raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \p at position 7

   ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-gbu5ivfl/phonenumbers/
! Push rejected, failed to compile Python app.
! Push failed

try to make individual steps smaller

to prevent useful content from disappearing in the embedded view mode. prefer more steps to longer ones that force crappy embedded vertical scrolling

Keroku install not working

Getting this error when using the deploy to Heroku button.

-----> Python app detected
! The latest version of Python 3 is python-3.6.2 (you are using python-3.4.3, which is unsupported).
! We recommend upgrading by specifying the latest version (python-3.6.2).
Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> Installing python-3.4.3
! Requested runtime (python-3.4.3) is not available for this stack (heroku-16).
! Aborting. More info: https://devcenter.heroku.com/articles/python-support
! Push rejected, failed to compile Python app.
! Push failed

Issue on international phone call

While testing the application deployed to Heroku we found that there is some kind of restriction when calling international numbers.

home_-_twilio_call_tracking

@atbaker could you have a look on this issue please? If you need any further information, please let me know.

EDIT:

After the call we made to +1 415-319-89xx the dashboard looks like:

home_-_twilio_call_tracking

It gives me the impression that the call was made successfully (no redirection was made). Is this the expected behaviour?

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.