def handle_third_response(request): digits = request.POST.get('Digits', '') twilio_response_three=Response() #twilio_response_three.say(digits) twilio_response_three.play('http://travellingscholar.com/ammi/message6.mp3') twilio_response_three.gather(action='respond4', numDigits=1) return twilio_response_three
def handle_call(request): r = Response() if request.GET['key'] == settings.TWILIO_KEY: kwargs = {'text':settings.GREETINGS, 'voice':None, 'language':None, 'loop':None} r.say(**kwargs) kwargs = {'action':settings.BASE_URL+'call_reference/?key='+request.GET['key'], 'method':'POST', 'timeout':settings.TWILIO_TIMEOUT, 'finish_on_key':settings.TWILIO_FINISHKEY} r.gather(**kwargs) return r
def voice(request): """Create a Twilio response object which gathers the callers input""" r = Response() with r.gather(action='/respond/') as g: g.say('Please enter a number to play phone buzz. Press the pound key when finished.', voice='woman') g.pause(length=10) return r
def gather_digits(request): twilio_response=Response() with twilio_response.gather(action='https://www.twilio.com/blog/respond/', numDigits=1) as g: g.say('Press one for a song, two to recieve an sms') g.pause(length=1) g.say('Press one for a song, two to recieve an sms') return twilio_response
def gather(request, action=None, method='POST', num_digits=None, timeout=None, finish_on_key=None): """See: http://www.twilio.com/docs/api/twiml/gather. Usage:: # urls.py urlpatterns = patterns('', # ... url(r'^gather/$', 'django_twilio.views.gather'), # ... ) """ r = Response() r.gather(action=action, method=method, numDigits=num_digits, timeout=timeout, finishOnKey=finish_on_key) return r
def ring(request): twilio_response = Response() message = 'Welcome to Fizz Buzz! Press up to three digits to start playing.' with twilio_response.gather(action='/response/', numDigits=3) as g: g.say(message) g.pause(length=1.5) g.say(message) return twilio_response
def gather_digits(request): twilio_response = Response() try: with twilio_response.gather(action='/phonebuzz/respond/', numDigits=3, finish_on_key='#') as g: g.say('Enter your FizzBuzz Number followed by a pound') except: return HttpResponseBadRequest return twilio_response
def receiveDigits(request): "Once the call has been made, this presents the user with an automated greeting" greeting = "Please press a number that would you like fizzbuzzed. Note, for your own convenience, keep the number 2 digits or less." returnMessage = Response() #Use <Gather> to collect digits that a caller enters into his or her telephone keypad. The data is then submitted. with returnMessage.gather(action='/respond/', numDigits=2) as initialGreeting: initialGreeting.say(greeting) initialGreeting.pause(length=3) return returnMessage
def gather_digits(request): twilio_response = Response() with twilio_response.gather(action='/respond/', numDigits=1) as g: g.say('Press one to hear a song, two to receive an SMS') g.pause(length=1) g.say('Press one to hear a song, two to receive an SMS') return twilio_response
def get(self, request): call, _ = ClientCall.objects.get_or_create(sid=request.GET["CallSid"]) call.request_bed_count() r = Response() r.say("How many beds do you need tonight?") with r.gather(finishOnKey="#", method="POST", action=reverse("phone:bed_count"), numdigits=1) as g: g.say("Press a number, then press pound") return r
def get(self, request): ClientCall.objects.get_or_create(sid=request.GET["CallSid"]) r = Response() r.say("""You have reached the Continuum. If you need immediate help, hang up and dial 9 1 1.""") with r.gather(finishOnKey="#", method="POST", action=reverse("phone:start"), numDigits=1) as g: g.say("If you need a bed tonight, press 1. To speak with a volunteer, press 0.") return r
def gather_digits(request): twilio_response = Response() with twilio_response.gather(action='/respond/', numDigits=1) as g: g.say('Press one to Notify Yaser, or press two to notify Nazih') g.pause(length=1) g.say('Press one to notify Yaser, or press two to notify Nazih') return twilio_response
def gather_digits(request): msg = 'Oye. Press a number to enter the world of Fizz Buzz. You can press maximum two digits' twilio_response = Response() with twilio_response.gather(action='/respond/', numDigits=2) as g: g.say(msg) g.pause(length=1) g.say(msg) return twilio_response
def gather_digits(request): msg = 'Press one to hear a song, two to receive an SMS, three to record a message.' twilio_response = Response() with twilio_response.gather(action='/respond_digits/', numDigits=1) as g: g.say(msg) g.pause(length=3) g.say(msg) return twilio_response
def gather_digits(request): twilio_response = Response() twilio_response.play('http://travellingscholar.com/ammi/message1.mp3') twilio_response.play('http://travellingscholar.com/ammi/message2.mp3') with twilio_response.gather(action='respond', numDigits=1) as g: #g.say('Assalaam walaikum, Ammi Tips par khush amdeed') #g.say(request) g.pause(length=1) return twilio_response
def gather_digits(request): msg = 'Oye. Press a number to enter the world of Fizz Buzz. You can press maximum two digits' twilio_response = Response() with twilio_response.gather(action='/respond/', numDigits=2) as g: g.say(msg) g.pause(length=1) g.say(msg) return twilio_response
def gather_digits(request): msg = 'Press one to hear a song, two to receive an SMS.' twilio_response = Response() with twilio_response.gather(action='/respond/', numDigits=1) as g: g.say(msg) g.pause(length=1) g.say(msg) return twilio_response
def gather_digits(request): twilio_response = Response() twilio_response.play('http://travellingscholar.com/ammi/message1.mp3') twilio_response.play('http://travellingscholar.com/ammi/message2.mp3') with twilio_response.gather(action='respond', numDigits=1) as g: #g.say('Assalaam walaikum, Ammi Tips par khush amdeed') #g.say(request) g.pause(length=1) return twilio_response
def login(request): r = Response() with r.gather( numDigits=6, timeout=10, finishOnKey='*', action=reverse('twiliorouter:handle_login'), method='POST' ) as g: g.say( 'please enter your 6 digit phone number to continue' ) return r
def notify_call(request, notification_uuid): r = Response() try: notification = Notification.objects.get(uuid=notification_uuid) except Notification.DoesNotExist: return r r.say("This is an oncaller notification.") message = notification.message if message: r.say(message, loop=2) #duke! r.play('http://dev.oncallr.com/static/audio/b2w.mp3') r.pause(length=1) r.say("Hit 1 to acknowledge, 2 to reject.", voice="woman") r.gather(action="http://www.oncallr.com/notification/call/response/{0}/".format(notification_uuid), method="POST", numDigits=1, timeout=2, finishOnKey=None) r.redirect(url="http://www.oncallr.com/notification/call/response/{0}/".format(notification_uuid), method="POST") return r
def get(self, request, client_call, pk): call = ClientCall.objects.get(pk=client_call) url = reverse("phone:verify_shelter_availability", kwargs={"pk": pk, "client_call": client_call}) r = Response() r.say("Hello, this is the Continuum, calling on behalf of") r.play(call.client_name) r.say("who is near") r.play(call.location_name) with r.gather(finishOnKey="#", method="POST", action=url, numDigits=1) as g: g.say("Do you %d beds available? Press 1 for yes, and 0 for no." % call.bed_count) return r
def handle_response(request): digits = request.POST.get('Digits', '') twilio_response = Response() #twilio_response.play('http://travellingscholar.com/ammi/firstmessage.mp3') if digits == '2': #digits3=request.POST.get('Digits','') twilio_response.play('http://travellingscholar.com/ammi/message3b.mp3') twilio_response.play('http://travellingscholar.com/ammi/message4.mp3') req = 'http://23ee1813.ngrok.com/respond' #r2 = gather_digits(req) twilio_response.gather(action='respond2', numDigits=1) #with twilio_response.gather(action='respond', numDigits=1) as g: #twilio_response.pause(length=1) #second_response= Response() if digits == '1': twilio_response.play('http://travellingscholar.com/ammi/message.mp3') # number = request.POST.get('From', '') # twilio_response.say('A text message is on its way') # twilio_response.sms('You looking lovely today!', to=number) return twilio_response
def handle_response(request): digits = request.POST.get('Digits', '') twilio_response = Response() #twilio_response.play('http://travellingscholar.com/ammi/firstmessage.mp3') if digits == '2': #digits3=request.POST.get('Digits','') twilio_response.play('http://travellingscholar.com/ammi/message3b.mp3') twilio_response.play('http://travellingscholar.com/ammi/message4.mp3') req = 'http://23ee1813.ngrok.com/respond' #r2 = gather_digits(req) twilio_response.gather(action='respond2', numDigits=1) #with twilio_response.gather(action='respond', numDigits=1) as g: #twilio_response.pause(length=1) #second_response= Response() if digits == '1': twilio_response.play('http://travellingscholar.com/ammi/message.mp3') # number = request.POST.get('From', '') # twilio_response.say('A text message is on its way') # twilio_response.sms('You looking lovely today!', to=number) return twilio_response
def welcome_options(request): r = Response() # check they are actually logged in if 'visitor' in request.session: visitor = request.session['visitor'] r.say('welcome {0:s}'.format(visitor['name'])) with r.gather( numDigits=1, timeout=10, finishOnKey='*', action=reverse('twiliorouter:handle_welcome_options'), method='POST' ) as g: g.say( 'press 1 to listen to messages, or press 2 to enter a number you want to connect to' )
def gather(request, action=None, method='POST', num_digits=None, timeout=None, finish_on_key=None): """See: http://www.twilio.com/docs/api/twiml/gather. Usage:: # urls.py urlpatterns = patterns('', # ... url(r'^gather/$', 'django_twilio.views.gather'), # ... ) """ r = Response() r.gather(action=action, method=method, numDigits=num_digits, timeout=timeout, finishOnKey=finish_on_key) return r
def hello(request): """A simple test view that returns a HttpResponse object.""" logger.debug("Calling hello") try: r = Response() with r.gather(numDigits=1, action=reverse("calls_gather"), method="GET") as g: g.say( """To hear your last tweet, press 1. Press 2 to record your message. Press any other key to start over.""" ) return r except Exception, ex: logger.debug(ex) return HttpResponse("<Response><Say>Error in Hello</Say></Response>", mimetype="text/xml")
def connect(request): # we are trying to connect to another account r = Response() if 'visitor' in request.session: with r.gather( numDigits=6, timeout=10, finishOnKey='*', action=reverse('twiliorouter:handle_connect'), method='POST' ) as g: g.say( 'please enter the 6 digit number you want to connect to' ) else: request.session['welcome_message'] = '' r.redirect(reverse('twiliorouter:welcome')) return r
def get(self, request, client_call, pk): call = ClientCall.objects.get(pk=client_call) url = reverse( 'phone:verify_shelter_availability', kwargs={'pk': pk, 'client_call': client_call} ) r = Response() r.say('Hello, this is the Continuum, calling on behalf of') r.play(call.client_name) r.say('who is near') r.play(call.location_name) with r.gather(finishOnKey='#', method='POST', action=url, numDigits=1) as g: g.say('Do you %d beds available? Press 1 for yes, and 0 for no.' % call.bed_count) return r
def handle_menu(): url = "{}?{}".format(request.base_url, request.query_string) response = Response() response.say(start_menu.format(request.args.get('name')), voice=voice) gather = response.gather(numDigits=1, action=url, method='POST') for key in keys: opt = request.args.get('opt_' + key) if opt is None: continue opt_args = opt.split(':') gather.say(opt_say.format(opt_args[1], key), voice=voice) return str(response)
def gather_digits(request): twilio_response = Response() with twilio_response.gather(action='/respond/', numDigits=2) as g: g.say('Press one to hear a song, two to receive an SMS') g.pause(length=1) g.say('Press one to hear a song, two to receive an SMS') """ client = TwilioRestClient(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN) client.messages.create( to="+917205771877", from_="+18329813555", body="thanks for showing interest", ) """ return twilio_response
def handle_menu(): url = "{}?{}".format(request.base_url, request.query_string) response = Response() response.say(start_menu.format(request.args.get('name')), voice=voice) gather = response.gather(numDigits=1, action=url, method='POST') for key in keys: opt = request.args.get('opt_' + key) if opt is None: continue opt_args = opt.split(':') gather.say(opt_say.format(opt_args[1], key), voice=voice) return str(response)
def hello_monkey(): """Root handler""" people = { '{}'.format(phone_dave): 'David', '{}'.format(phone_kenna): 'Makenna', '{}'.format(phone_brit): 'Britiany', '{}'.format(phone_rob): 'Robert', } name = people.get(request.args.get('From', ''), 'Monkey') resp = Response() resp.say("Hello " + name) resp.play("http://demo.twilio.com/hellomonkey/monkey.mp3") with resp.gather(numDigits=1, action="/hello-monkey/handle-key/", method="POST") as g: g.say('To speak to a real monkey, press 1. ' 'Press 2 to record your own monkey howl. ' 'Press 3 to talk to customer support. ' 'Press any other key to start over.') return str(resp)
def twilio_call_start(request, calllog_id): call_log = get_object_or_404(CallLog, id=int(calllog_id)) call_log.status = "picked-up" call_log.log["start"] = dict(request.POST) call_log.log["start"]["_request"] = get_request_log_info(request) call_log.save() resp = TwilioResponse() resp.say("Hello from Gov Track.") g = resp.gather( action=request.build_absolute_uri("/poll/_twilio/call-input/" + str(call_log.id)), numDigits=1, timeout=20, ) g.say("Press one to be connected to the office of %s %s. Press two if you did not request this call. Or simply hang up if you do not want your call to be connected." % ( call_log.target.get_title(), call_log.target.person.lastname)) resp.say("Oooo too slow. We're going to hang up now.") return resp
def twilio_call_start(request, call_id): report = get_object_or_404(WhipReport, id=int(call_id)) report.call_status = "picked-up" report.call_log["start"] = dict(request.POST) report.call_log["start"]["_request"] = get_request_log_info(request) report.save() resp = TwilioResponse() resp.say("Hello from Gov Track.") g = resp.gather( action=build_twilio_callback_url(request, report, "call-input"), numDigits=1, timeout=20, ) g.say("Press one to be connected to the office of %s %s. Press two if you did not request this call. Or simply hang up if you do not want your call to be connected." % ( report.target.get_title(), report.target.person.lastname)) resp.say("Oooo too slow. We're going to hang up now.") return resp
def twilio_call_start(request, call_id): report = get_object_or_404(WhipReport, id=int(call_id)) report.call_status = "picked-up" report.call_log["start"] = dict(request.POST) report.call_log["start"]["_request"] = get_request_log_info(request) report.save() resp = TwilioResponse() resp.say("Hello from Gov Track.") g = resp.gather( action=build_twilio_callback_url(request, report, "call-input"), numDigits=1, timeout=20, ) g.say( "Press one to be connected to the office of %s %s. Press two if you did not request this call. Or simply hang up if you do not want your call to be connected." % (report.target.get_title(), report.target.person.lastname)) resp.say("Oooo too slow. We're going to hang up now.") return resp
def answer_call(): r = Response() if request.form['From'] != config.intercom: r.reject(reason='rejected') if not config.auth: r.verbs.extend(grant_access()) else: with r.gather(action=url_for('.check_input'), numDigits=4, timeout=4) as g: g.say('Please enter a pin or hold.') try: contact = models.Contact.objects.get(pk=config.forward) r.dial(contact.phone_number) except models.Contact.DoesNotExist: pass r.say('Goodbye.') return r
def twilio_call_start(request, calllog_id): call_log = get_object_or_404(CallLog, id=int(calllog_id)) call_log.status = "picked-up" call_log.log["start"] = dict(request.POST) call_log.log["start"]["_request"] = get_request_log_info(request) call_log.save() resp = TwilioResponse() resp.say("Hello from Gov Track.") g = resp.gather( action=request.build_absolute_uri("/poll/_twilio/call-input/" + str(call_log.id)), numDigits=1, timeout=20, ) g.say( "Press one to be connected to the office of %s %s. Press two if you did not request this call. Or simply hang up if you do not want your call to be connected." % (call_log.target.get_title(), call_log.target.person.lastname)) resp.say("Oooo too slow. We're going to hang up now.") return resp
def handle_conference_line(): whitelist = request.args.getlist("whitelist") if len(whitelist) > 0: if request.args["From"] not in whitelist: resp = Response() resp.say("Sorry, you are not authorized to call this number") return str(resp) room = request.args.get("room", False) if room: resp = Response() with resp.dial() as d: d.conference(room) return str(resp) # Gather the room code resp = Response() with resp.gather(numDigits=3, action="/conference-line/connect", method="GET") as g: g.say("Enter a 3-digit room code") return str(resp)
def voice(request): r = Response() with r.gather(action="/respond/") as g: g.say("Please enter a number to play phone buzz. Press the pound key when finished.", voice="woman") g.pause(length=10) return r
def handle_second_response(request): digits = request.POST.get('Digits', '') twilio_response_two = Response() twilio_response_two.play('http://travellingscholar.com/ammi/message5a.mp3') twilio_response_two.gather(action='respond3', numDigits=1) return twilio_response_two
def get_phone_intro(request): r = Response() r.gather(action='/call/getScore/',method='POST').say('Welcome to the Kay You Engineering EXPO Scoring System. For score reports, please enter your team number and press pound.',voice='woman',language='en-gb') return r