@@ -3,7 +3,7 @@ slug: dial-outbound-phone-calls-python-bottle
33meta: A tutorial that shows how to dial outbound phone calls with a Bottle web application built with Python 3.
44category: post
55date: 2016-08-30
6- modified: 2017-05-11
6+ modified: 2017-06-16
77headerimage: /img/160830-phone-calls-bottle/header.jpg
88headeralt: Bottle, Python and Twilio logos. Copyright their respective owners.
99
@@ -121,7 +121,7 @@ NGROK_BASE_URL = os.environ.get('NGROK_BASE_URL', 'https://c6c6d4e8.ngrok.io')
121121@route (' /' )
122122def index ():
123123 """
124- Returns a standard text response to show the app is up and running.
124+ Returns a standard text response to show the app is up and running.
125125 """
126126 return Response(" Bottle app running!" )
127127
@@ -223,17 +223,17 @@ NGROK_BASE_URL = os.environ.get('NGROK_BASE_URL', 'https://c6c6d4e8.ngrok.io')
223223@route (' /' )
224224def index ():
225225 """
226- Returns a standard text response to show the app is up and running.
226+ Returns a standard text response to show the app is up and running.
227227 """
228228 return Response(" Bottle app running!" )
229229
230230
231231@post (' /twiml' )
232232def twiml_response ():
233233 """
234- Provides TwiML instructions in response to a Twilio POST webhook
235- event so that Twilio knows how to handle the outbound phone call
236- when someone picks up the phone.
234+ Provides TwiML instructions in response to a Twilio POST webhook
235+ event so that Twilio knows how to handle the outbound phone call
236+ when someone picks up the phone.
237237 """
238238 response = twiml.Response()
239239 response.say(" Sweet, this phone call is answered by your Bottle app!" )
@@ -244,14 +244,15 @@ def twiml_response():
244244@route (' /dial-phone/<outbound_phone_number>' )
245245def outbound_call (outbound_phone_number ):
246246 """
247- Uses the Twilio Python helper library to send a POST request to
248- Twilio telling it to dial an outbound phone call from our specific
249- Twilio phone number (that phone number must be owned by our
250- Twilio account).
247+ Uses the Twilio Python helper library to send a POST request to
248+ Twilio telling it to dial an outbound phone call from our specific
249+ Twilio phone number (that phone number must be owned by our Twilio
250+ account).
251251 """
252252 # the url must match the Ngrok Forwarding URL plus the route defined in
253253 # the previous function that responds with TwiML instructions
254- twilio_client.calls.create(to = OUTBOUND_NUMBER , from_ = BLOG_POST_NUMBER ,
254+ twilio_client.calls.create(to = outbound_phone_number,
255+ from_ = BLOG_POST_NUMBER ,
255256 url = NGROK_BASE_URL + ' /twiml' )
256257 return Response(' phone call placed to ' + outbound_phone_number + ' !' )
257258
0 commit comments