diff --git a/README.rst b/README.rst index 3f6bf84..b4fdfdf 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,7 @@ rapidsms-twilio `Twilio `_ backend for the `RapidSMS `_ project. + Requirements ------------ @@ -32,10 +33,10 @@ Add the following to your existing ``INSTALLED_BACKENDS`` configuration in your "twilio-backend": { "ENGINE": "rtwilio.outgoing.TwilioBackend", 'config': { - 'account_sid': 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', # (required) - 'auth_token': 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY', # (required) - 'number': '(###) ###-####', # your Twilio phone number (required) - # 'callback': 'http:///twilio/status-callback/', # optional callback URL + 'account_sid': 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', # (required) + 'auth_token': 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY', # (required) + 'number': '(###) ###-####', # your Twilio phone number (required) + # 'callback': 'http:///twilio/status-callback/', # optional callback URL } }, } @@ -55,4 +56,52 @@ backend. You can do this like so:: Now inbound Twilio messages can be received at ``/backend/twilio/`` and outbound messages will be sent via the Twilio backend. + +Callback URL +------------ + +Delivery Report +=============== + +RapidSMS can take advantage of Twilio's callback URL functionality. This is +useful if you'd like to track the status of a message after it's been passed to +Twilio for processing. Twilio will use a callback URL to notify us. Enabling +this feature will allow you to view delivery reports, for each message, in the +Django admin. + +1. Make sure ``rtwilio`` is in ``INSTALLED_APPS``:: + + INSTALLED_APPS = ( + # other apps + 'rtwilio', + ) + +2. Add the callback view to your urlconf:: + + urlpatterns = patterns('', + # ... + url(r'^backend/twilio/status-callback/$', status_callback, + name='twilio-status-callback'), + ) + +3. Add the necessary database tables (omit ``--migrate`` if you're not using South):: + + python manage.py syncdb --migrate + +4. Add the full callback URL to your settings:: + + INSTALLED_BACKENDS = { + # ... + # other backends, if any + "twilio-backend": { + "ENGINE": "rtwilio.outgoing.TwilioBackend", + 'config': { + # same as before.. + 'callback': 'http:///backend/twilio/status-callback/', + } + }, + } + +You can view delivery reports in the Django admin. + Development by `Caktus Consulting Group `_. diff --git a/rtwilio/views.py b/rtwilio/views.py index 4427c13..4ffaa95 100644 --- a/rtwilio/views.py +++ b/rtwilio/views.py @@ -1,4 +1,5 @@ from django.http import HttpResponse +from django.views.decorators.csrf import csrf_exempt from rapidsms.backends.http.views import GenericHttpBackendView @@ -16,6 +17,7 @@ class TwilioBackendView(GenericHttpBackendView): form_class = TwilioForm +@csrf_exempt def status_callback(request): form = StatusCallbackForm(request.POST or None) if form.is_valid():