Reputation: 8570
All the examples of using django-twilio to send an SMS assume that this is initiated by receiving one first, that my application is responding to an incoming sms by sending another one.
But how do I initiate an SMS call? I need to send an SMS notifying specific users that a new booking has come in.
This is what I want to do, but all I get is the XML that twilio needs. What is the missing step?
@login_required @user_passes_test(is_webmaster) @twilio_view def send_test_sms(request):
r = twiml.Response() r.message('Test SMS from my app', to="+nnnnnnnn") return r
Upvotes: 1
Views: 311
Reputation: 1244
Twilio devangel here, I also maintain the django-twilio library :)
You can send outbound SMS and initiate outbound voice calls using the rest API like so:
# import this into your view / controller
from django_twilio.client import twilio_client
# Within your function, use the REST API:
m = twilio_client.messages.create(
to='TO_NUMBER',
from_='FROM_NUMBER',
body='Join me and together we can rule the galaxy as father and son!'
)
print m.status
>>> 'sent'
You can read more on the REST API client in twilio-python over here
Upvotes: 2