def route_hotline_forward2(api_version, language, call_id, helper_id): resp = VoiceResponse() if language not in ["de", "en-gb"]: resp.redirect('/v1/hotline/error/language') return str(resp) if api_version == "v1": forward_call_result = routing.get_params_dict(request) dial_call_status = forward_call_result["DialCallStatus"] if dial_call_status == "completed": resp.say(hotline_translation['after_forward_successful'][language], voice='woman', language=language) else: forwarding.flag_helper(call_id, helper_id, dial_call_status) call_scripts.reject_call(call_id, helper_id) resp.say( hotline_translation['after_forward_not_successful'][language], voice='woman', language=language) else: resp.redirect('/v1/hotline/error/api_version') return str(resp)
def salary(language, age, gender, work): response = VoiceResponse() if 'Digits' in request.values: salary = request.values['Digits'] if int(language) == 1: response.say(en['message13'], voice='Polly.Aditi', language="hi-IN") response.say(en['message9'], voice='Polly.Aditi', language="hi-IN") response.redirect('/answer/' + language + '/' + age + '/' + gender + '/' + work + '/' + salary) return str(response) elif int(language) == 2: response.say(hi['message13'], voice='Polly.Aditi', language="hi-IN") response.say(hi['message9'], voice='Polly.Aditi', language="hi-IN") response.redirect('/answer/' + language + '/' + age + '/' + gender + '/' + work + '/' + salary) return str(response) elif int(language) == 3: response.say(ka['message13'], voice='Polly.Aditi', language="hi-IN") response.say(ka['message9'], voice='Polly.Aditi', language="hi-IN") response.redirect('/answer/' + language + '/' + age + '/' + gender + '/' + work + '/' + salary) return str(response) else: response.redirect('/index') return str(response) else: response.redirect('/index') return str(response)
def call_agent(): resp = VoiceResponse() call = client.calls.create(to="+17204412178", from_="+19704091327", url="http://91c9adb2.ngrok.io/conf-mod") resp.redirect("/hold-handle") return str(resp)
def gather(): resp = VoiceResponse() # If digits were included if 'Digits' in request.values: choice = request.values['Digits'] # If correct code if choice == '965312': resp.say('Identification code for Manager Mark. The flag is.') resp.pause(length=1) resp.say( 'C.T.F. Curly brace. D.T.M.F. underscore. I. s. underscore. A.w.e.s.o.m.e. Curly brace.' ) resp.pause(length=2) resp.say( 'That is. C.T.F Curly brace. D.T.M.F. underscore. I.s. underscore. A.w.e.s.o.m.e. Curly brace.' ) resp.pause(length=1) resp.say('Goodbye.') return str(resp) else: resp.say('Incorrect identification code. Goodbye!') return str(resp) # No digits resp.redirect('/voice') return str(resp)
def gather(): resp = VoiceResponse() if 'Digits' in request.values: choice = request.values['Digits'] if choice == '1': string = choice1() return string elif choice == '2': string = choice2() return string elif choice == '3': string = choice3() return string elif choice == '4': string = choice4() return string elif choice == '5': string = choice5() return string else: resp.say("Sorry, I don't understand that choice.") resp.redirect('/voice') return str(resp)
def get_cur(): global index, choice response = VoiceResponse() n = current if n["option"] == "speak": response.say(message=n["message"]) elif n["option"] == "directory": response.say(message="Directory: ") for key, value in n.items(): if key != "option": response.say(message=key + " at " + value) elif n["option"] == "end": response.hangup() elif n["option"] == "redirect": response.dial(n['redirect']) elif n["option"] == "choice": choice = True choices = n['choices'] with response.gather(numDigits=1, action="/gather") as gather: for i in range(len(choices)): gather.say(message="Press" + str(i) + " to " + choices[i]) response.redirect("/cur") response.redirect('/next') return str(response)
def language(): response = VoiceResponse() if 'Digits' in request.values: language = int(request.values['Digits']) if language == 1: response.say(en['message4'], voice='Polly.Aditi', language="hi-IN") response.say(en['message5'], voice='Polly.Aditi', language="hi-IN") gather = Gather(num_digits=2, action='/age/' + str(language)) response.append(gather) return str(response) elif language == 2: response.say(hi['message4'], voice='Polly.Aditi', language="hi-IN") response.say(hi['message5'], voice='Polly.Aditi', language="hi-IN") gather = Gather(num_digits=2, action='/age/' + str(language)) response.append(gather) return str(response) elif language == 3: response.say(ka['message4'], voice='Polly.Aditi', language="hi-IN") response.say(ka['message5'], voice='Polly.Aditi', language="hi-IN") gather = Gather(num_digits=2, action='/age/' + str(language)) response.append(gather) return str(response) else: response.redirect('/index') return str(response) else: return str(response)
def post(self, request): if request.session['index'] >= len(request.session['obj-keys']): voice_response = VoiceResponse() voice_response.redirect( reverse('feature-phone:qualitative-question-instructions')) return HttpResponse(voice_response, content_type='application/xml') return super(PromptCommentView, self).post(request)
def next_step(): global current current = get_next() get_cur() response = VoiceResponse() response.redirect('/cur') return str(response)
def choose_movie(request: HttpRequest) -> HttpResponse: validate_django_request(request) vr = VoiceResponse() digits = request.POST.get('Digits') try: theater = Theater.objects.get(digits=digits) except Theater.DoesNotExist: vr.say('Please select a theater from the list.') vr.redirect(reverse('choose-theater')) else: with vr.gather( action=f'{reverse("list-showtimes")}?theater={theater.id}', finish_on_key='#', timeout=20, ) as gather: gather.say('Please choose a movie and press #') movies = (Movie.objects.filter( digits__isnull=False).order_by('digits')) for movie in movies: gather.say(f'For {movie.title} press {movie.digits}') vr.say('We did not receive your selection') vr.redirect(reverse('choose-theater')) return HttpResponse(str(vr), content_type='text/xml')
def waitForBotRespsonse(ntry=1): caller = request.form.get('Caller') bot = converations[caller] if (int(ntry) > 7): return str( buildTwilioResponse('Sorry I could not reply from the application', hangUp=True)) msg = bot.get() bot._lastAccessed = time.time() loop = time.time() if not msg: while time.time() - loop <= 10: try: msg = bot.get() if msg: break time.sleep(.5) except Exception as e: print(str(e)) pass bot._lastAccessed = time.time() if not msg: resp = VoiceResponse() url = '/wait/' + str(int(ntry) + 1) resp.redirect(url, method='POST') return str(resp) else: return str( buildTwilioResponse(msg.get('msgs'), msg.get('endOfConversation'), msg.get('waitForResponse'), msg.get('routeToMainMenu'), hangUp=msg.get('hangUp'), dtmf=msg.get('dtmf')))
def schedule_prompt(params, campaign): """ Prompt the user to schedule calls """ if not params or not campaign: abort(400) resp = VoiceResponse() g = Gather(num_digits=1, timeout=3, method="POST", action=url_for("call.schedule_parse", **params)) existing_schedule = ScheduleCall.query.filter_by( campaign_id=campaign.id, phone_number=params['userPhone']).first() if existing_schedule and existing_schedule.subscribed: play_or_say(g, campaign.audio('msg_alter_schedule'), lang=campaign.language_code) else: play_or_say(g, campaign.audio('msg_prompt_schedule'), lang=campaign.language_code) resp.append(g) # in case the timeout occurs, we need a redirect verb to ensure that the call doesn't drop params['scheduleSkip'] = 1 resp.redirect(url_for('call._make_calls', **params)) return str(resp)
def execute(self): resp = self.handle_hours() if resp is not None: return str(resp) resp = VoiceResponse() gather = Gather() gather.play(self.section_data['play_sample'], digits=1) pause = 2 if 'pause' in self.section_data.keys(): pause = int(self.section_data['pause']) gather.pause(length=pause) resp.append(gather) if ('no_input_max_loops' in self.section_data.keys() and self.loop_count >= int( self.section_data['no_input_max_loops'])): if 'no_input_action_on_max_loops' in self.section_data.keys(): resp.redirect( self.url_of( '/ivr/action/' + self.section_data['no_input_action_on_max_loops'])) else: resp.hangup() if 'no_input_sample' in self.section_data.keys(): resp.play(self.section_data['no_input_sample']) resp.redirect(self.url_of(f'/ivr/menu?loop_count={self.loop_count}')) return str(resp)
def verify(): twilio_api = TwilioApi(opengateapp_config) if db.get_response_received() == False: response = VoiceResponse() response.redirect('/verify/') return str(response) response = db.get_sms_response() if response == "Yes": response = VoiceResponse() response.play('', digits='www99') twilio_api.gate_opened_notificiation() db.reset_response() return str(response) elif response == "No": response = VoiceResponse() response.say("Denied") db.reset_response() return str(response) else: response = VoiceResponse() response.redirect('/verify/') return str(response)
def get_pin(): response = VoiceResponse() gather = Gather(input='dtmf', timeout=10, num_digits=4) gather.say('Please enter your conference pin.') response.append(gather) response.redirect(url_for('conference.join'), method='GET') return str(response)
def voice(): """Respond to incoming phone calls with a menu of options""" # Start our TwiML response resp = VoiceResponse() # If Twilio's request to our app included already gathered digits, # process them if 'Digits' in request.values: # Get which digit the caller chose choice = request.values['Digits'] # <Say> a different message depending on the caller's choice if choice == '1': resp.say('You selected sales. Good for you!') return str(resp) elif choice == '2': resp.say('You need support. We will help!') return str(resp) else: # If the caller didn't choose 1 or 2, apologize and ask them again resp.say("Sorry, I don't understand that choice.") # Start our <Gather> verb gather = Gather(num_digits=1) gather.say('For sales, press 1. For support, press 2.') resp.append(gather) # If the user doesn't select an option, redirect them into a loop resp.redirect('/voice') return str(resp)
def _redirect_welcome(): response = VoiceResponse() response.say("Returning to the main menu") response.redirect(url_for('welcome')) return twiml(response)
def gather(): """Processes results from the <Gather> prompt in /voice""" # Start our TwiML response resp = VoiceResponse() # If Twilio's request to our app included already gathered digits, # process them if 'Digits' in request.values: # Get which digit the caller chose choice = request.values['Digits'] # <Say> a different message depending on the caller's choice if choice == '1': resp.say('You selected sales. Good for you!') return str(resp) elif choice == '2': resp.say('You need support. We will help!') return str(resp) else: # If the caller didn't choose 1 or 2, apologize and ask them again resp.say("Sorry, I don't understand that choice.") # If the user didn't choose 1 or 2 (or anything), send them back to /voice resp.redirect('/voice') return str(resp)
def route_hotline_forward1(api_version, language, call_id): resp = VoiceResponse() if language not in ["de", "en-gb"]: resp.redirect('/v1/hotline/error/language') return str(resp) if api_version == "v1": forward_helper_query_result = forwarding.find_forward_helper(call_id) if forward_helper_query_result["status"] == "ok": resp.say(hotline_translation['forward_successful'][language], voice='woman', language=language) phone_number = forward_helper_query_result["phone_number"] helper_id = forward_helper_query_result['helper_id'] resp.dial( phone_number, action= f"/{api_version}/hotline/{language}/forward2/{call_id}/{helper_id}", timeout=15) else: resp.say(hotline_translation['forward_not_successful'][language], voice='woman', language=language) enqueue.enqueue(call_id) else: resp.redirect('/v1/hotline/error/api_version') return str(resp)
def callQ_handle(): resp = VoiceResponse() conferences = client.conferences.list(status="in-progress", friendly_name="TEST") if(conferences == []) resp.redirect("/pop-first") resp.play(hold_mp3, loop=1) return str(resp)
def answer(): n = int(request.args.get('question')) i = int(request.args.get('repeat')) score = int(request.args.get('score')) db = get_db() question = db.execute( 'SELECT correct, feedback FROM questions WHERE question_id=?', str(n) ).fetchone() correct = int(question[0]) selected_option = request.form['Digits'] response = VoiceResponse() if correct == int(selected_option): response.say("That's right!") score += 1 else: response.say("So close!") # returns feedback response.say(question[1]) # enters into database _insert_response(n, selected_option) # repeats 3 questions for demo purposes (simulates the process of waiting for an agent) if i < 2: response.redirect(url_for('ask', repeat=i + 1, score=score)) else: response.redirect(url_for('gameover', correct=score, total=i)) return twiml_resp(response)
def playstation(request): dig = request.GET['Digits'] skipintro = False if 'played' in request.GET: skipintro = True try: song = stationnextsonginternal(t.id) sid = song.id except: rn = Song.objects.last().id x = True while x: sid = random.randint(9000, rn) if Song.objects.get(id=sid).filetype == 'mp3': x = False resp = VoiceResponse() if not skipintro: resp.say( f"Thank you for chosing station number {dig}. At any point you can press 1 followed by the pound key to dislike and skip this song. Please be kind. The algorithm is still in development.", voice='woman', language='en-gb') gather = Gather(action='/twilio/dislike/' + str(dig) + '/' + str(sid), method='GET', numDigits='1') resp.append(gather) gather.play('http://5f1c429e.ngrok.io/twilio/playsong/' + str(sid)) resp.redirect(f'/twilio/playstation?Digits={dig}&played=yes', method='GET') return HttpResponse(resp)
def checkZip(): """Processes results from the <Gather> prompt in /voice""" # Start our TwiML response resp = VoiceResponse() # If Twilio's request to our app included already gathered digits, # process them if 'Digits' in request.values: # Get which digit the caller chose choice = request.values['Digits'] resp.say("Here is the zipcode you entered:", voice='alice') resp.say(choice[0]) resp.say(choice[1]) resp.say(choice[2]) resp.say(choice[3]) resp.say(choice[4]) # validate zipcode if (zipcodes.is_real(choice)): resp.redirect('/list_places') resp.say("Zip code not valid.", voice='alice') resp.redirect('/answer') return str(resp)
def gather(): """Processes results from the <Gather> prompt in /voice""" # Start our TwiML response resp = VoiceResponse() # If Twilio's request to our app included already gathered digits, # process them if 'Digits' in request.values: # Get which digit the caller chose choice = request.values['Digits'] # <Say> a different message depending on the caller's choice if choice == '1': resp.say('You selected sales. Good for you!') return str(resp) elif choice == '2': resp.say('You need support. We will help!') return str(resp) else: # If the caller didn't choose 1 or 2, apologize and ask them again resp.say("Sorry, I don't understand that choice.") # If the user didn't choose 1 or 2 (or anything), send them back to /voice resp.redirect('/voice') return str(resp)
def german_question_3(language, call_id): # Start our TwiML response resp = VoiceResponse() gather = Gather(num_digits=6, finish_on_key="#") if 'Digits' in request.values: # Get which digit the caller chose digits = request.values['Digits'] finished_on_key = request.values['FinishedOnKey'] if len(digits) == 5 and finished_on_key == "#": edit_call(call_id, "zip_code", digits) resp.say(hotline_translation["question_3_answer_yes"][language], voice="woman", language=language) return str(resp) else: gather.say( hotline_translation["question_3_answer_unknown"][language], voice="woman", language=language) else: gather.say(hotline_translation["question_3_text_1"][language], voice="woman", language=language) gather.say(hotline_translation["question_3_text_2"][language], voice="woman", language=language) resp.append(gather) resp.redirect(f'/hotline/{language}/question/3/{call_id}') return str(resp)
def voice(): """Respond to incoming phone calls with a menu of options""" # Start our TwiML response resp = VoiceResponse() # If Twilio's request to our app included already gathered digits, # process them if 'Digits' in request.values: # Get which digit the caller chose choice = request.values['Digits'] # <Say> a different message depending on the caller's choice if choice == '1': resp.say('You selected sales. Good for you!') return str(resp) elif choice == '2': resp.say('You need support. We will help!') return str(resp) else: # If the caller didn't choose 1 or 2, apologize and ask them again resp.say("Sorry, I don't understand that choice.") # Start our <Gather> verb gather = Gather(numDigits=1) gather.say('For sales, press 1. For support, press 2.') resp.append(gather) # If the user doesn't select an option, redirect them into a loop resp.redirect('/voice') return str(resp)
def voice(): """Respond to incoming phone calls with a menu of options""" # Start our TwiML response resp = VoiceResponse() caller = request.values.get('From') caller = caller[4:] # verify the phone number has access to the call from_number = [x for x in KNOWN_PARTICIPANTS if caller in x] if not from_number: resp.say("Sorry, I don't recognize the number you're calling from.") return str(resp) name = KNOWN_PARTICIPANTS.get(from_number[0]) #start_verification(caller) # Start our <Gather> verb gather = Gather(num_digits=6, action='/gather') gather.say( "Welcome {}. Please enter the 6 digit code sent to your device.". format(name)) resp.append(gather) # If the user doesn't select an option, redirect them into a loop resp.redirect('/voice') return str(resp)
def german_question_2(language, call_id): # Start our TwiML response resp = VoiceResponse() if 'Digits' in request.values: # Get which digit the caller chose choice = request.values['Digits'] # <Say> a different message depending on the caller's choice if choice in ["1", "2"]: edit_call(call_id, "answer_2", int(choice)) resp.redirect(f"/hotline/{language}/question/3/{call_id}") return str(resp) else: # If the caller didn't choose 1 or 2, apologize and ask them again resp.say( hotline_translation["question_2_answer_unknown"][language], voice="woman", language=language) gather = Gather(num_digits=1) gather.say(hotline_translation["question_2_text_1"][language], voice="woman", language=language) resp.append(gather) resp.redirect(f'/hotline/{language}/question/2/{call_id}') return str(resp)
def answer_call2(): global globalSid """Respond to incoming phone calls with a brief message.""" # Start our TwiML response resp = VoiceResponse() try: globalSid = request.values['CallSid'] url = "http://localhost:5005/conversations/" + request.values[ 'CallSid'] + "/respond" payload = "{\"query\":\"" + request.values['SpeechResult'] + "\"}" headers = { 'content-type': "application/json", 'cache-control': "no-cache", 'postman-token': "9f483742-6dba-b699-fe81-7e3f5e474af8" } response = requests.request("POST", url, data=payload, headers=headers) responseData = json.loads(response.text) print('Human -> ' + request.values['SpeechResult']) print('Bot -> ' + responseData[0]['text']) spit_out_text = responseData[0]['text'] resp.say(spit_out_text, voice='woman', language='en') resp.redirect('/answer') except Exception as e: print(str(e)) resp.say('I am having trouble understanding you.', voice='woman', language='en') resp.redirect('/answer') return str(resp)
def post(self, request): """ Serve the Twilio client directions for collecting input. """ voice_response = VoiceResponse() if self.accept_keypress: keypress_timeout = 0 if self.accept_speech else self.timeout gather = Gather(input='dtmf', action=reverse(self.submit_view), finish_on_key='', timeout=keypress_timeout, num_digits=1) self.ask(request, gather) voice_response.append(gather) else: self.ask(request, voice_response) if self.accept_speech: end_keys = SKIP_DIGIT + REPEAT_DIGIT + digits if self.accept_keypress else '' voice_response.record(action=reverse(self.submit_view), play_beep=self.play_beep, timeout=self.timeout, max_length=self.recording_max_duration, recording_status_callback=reverse( self.recording_callback), finish_on_key=end_keys) self.fallback(voice_response) voice_response.redirect(reverse(self.submit_view)) return HttpResponse(voice_response, content_type='application/xml')
def record(): client = Client(account_sid, auth_token) # Start our TwiML response response = VoiceResponse() # Use <Say> to give the caller some instructions response.say('Hello this is LINC. What would you like to talk about?') # Use <Record> to record the caller's message response.record(transcribe=True, playBeep=True, timeout=4) # response.pause(length=3) client = Client(account_sid, auth_token) trans_list = client.transcriptions.list() for transcription in trans_list: latest_transcript = transcription.transcription_text status = transcription.status if (latest_transcript != None): unicodedata.normalize('NFKD', latest_transcript).encode('ascii', 'ignore') print(status) print(transcription.sid) print(latest_transcript) transcription.delete() break else: response.say("I'm sorry. I didn't get that. Can you repeat it?") print(latest_transcript != "hello") if (latest_transcript != "hello"): print("boolean worked") response.redirect("http://4b930e15.ngrok.io/voice_response") response.hangup() return str(response)
def post(self, request): question_pk = request.session['obj-keys'][request.session['index']] question = Question.objects.get(pk=question_pk) respondent = get_respondent(request.session) if request.POST.get('Digits') == 'hangup': return HttpResponse(content_type='application/xml') elif request.POST.get('Digits') == SKIP_DIGIT or request.session.get( 'repeat'): if request.session.get('repeat'): response = Response.objects.get( respondent=respondent, prompt_type=ContentType.objects.get_for_model(Question), prompt_id=question_pk, ) response.url = request.POST['RecordingUrl'] response.save() request.session['index'] += 1 request.session['repeat'] = False voice_response = VoiceResponse() voice_response.redirect( reverse('feature-phone:prompt-qualitative-question')) return HttpResponse(voice_response, content_type='application/xml') else: comment = web_models.Comment.objects.create( question=question.related_object, respondent=respondent.related_object, language=get_language(), ) response = make_response(respondent, question, comment) response.url = request.POST['RecordingUrl'] response.save() return super(ConfirmCommentView, self).post(request)
def complete(): params, campaign = parse_params(request) i = int(request.values.get('call_index', 0)) if not params or not campaign: abort(400) (uid, prefix) = parse_target(params['targetIds'][i]) (current_target, cached) = Target.get_or_cache_key(uid, prefix) call_data = { 'session_id': params['sessionId'], 'campaign_id': campaign.id, 'target_id': current_target.id, 'call_id': request.values.get('CallSid', None), 'status': request.values.get('DialCallStatus', 'unknown'), 'duration': request.values.get('DialCallDuration', 0) } try: db.session.add(Call(**call_data)) db.session.commit() except SQLAlchemyError: current_app.logger.error('Failed to log call:', exc_info=True) resp = VoiceResponse() if call_data['status'] == 'busy': play_or_say(resp, campaign.audio('msg_target_busy'), title=current_target.title, name=current_target.name, lang=campaign.language_code) # TODO if district offices, try another office number i = int(request.values.get('call_index', 0)) if i == len(params['targetIds']) - 1: # thank you for calling message play_or_say(resp, campaign.audio('msg_final_thanks'), lang=campaign.language_code) else: # call the next target params['call_index'] = i + 1 # increment the call counter calls_left = len(params['targetIds']) - i - 1 play_or_say(resp, campaign.audio('msg_between_calls'), calls_left=calls_left, lang=campaign.language_code) resp.redirect(url_for('call.make_single', **params)) return str(resp)
def voice(): """Respond to incoming phone calls with a menu of options""" # Start our TwiML response resp = VoiceResponse() # Start our <Gather> verb gather = Gather(num_digits=1, action='/gather') gather.say('For sales, press 1. For support, press 2.') resp.append(gather) # If the user doesn't select an option, redirect them into a loop resp.redirect('/voice') return str(resp)
def schedule_parse(): """ Handle schedule response entered by user Required Params: campaignId, Digits """ params, campaign = parse_params(request) resp = VoiceResponse() if not params or not campaign: abort(400) schedule_choice = request.values.get('Digits', '') if current_app.debug: current_app.logger.debug(u'entered = {}'.format(schedule_choice)) if schedule_choice == "1": # schedule a call at this time every day play_or_say(resp, campaign.audio('msg_schedule_start'), lang=campaign.language_code) scheduled = True schedule_created.send(ScheduleCall, campaign_id=campaign.id, phone=params['userPhone'], location=params['userLocation']) elif schedule_choice == "9": # user wishes to opt out play_or_say(resp, campaign.audio('msg_schedule_stop'), lang=campaign.language_code) scheduled = False schedule_deleted.send(ScheduleCall, campaign_id=campaign.id, phone=params['userPhone']) else: # because of the timeout, we may not have a digit scheduled = False params['scheduled'] = scheduled resp.redirect(url_for('call._make_calls', **params)) return str(resp)
def location_parse(): """ Handle location entered by the user. Required Params: campaignId, Digits """ params, campaign = parse_params(request) if not params or not campaign: abort(400) location = request.values.get('Digits', '') # Override locate_by attribute so locate_targets knows we're passing a zip # This allows call-ins to be made for campaigns which otherwise use district locate_by campaign.locate_by = LOCATION_POSTAL # Skip special, because at this point we just want to know if the zipcode is valid located_target_ids = locate_targets(location, campaign, skip_special=True) if current_app.debug: current_app.logger.debug(u'entered = {}'.format(location)) if not located_target_ids: resp = VoiceResponse() play_or_say(resp, campaign.audio('msg_invalid_location'), lang=campaign.language_code) return location_gather(resp, params, campaign) params['userLocation'] = location call_session = Session.query.get(params['sessionId']) if not call_session.location: call_session.location = location db.session.add(call_session) db.session.commit() resp = VoiceResponse() resp.redirect(url_for('call._make_calls', **params)) return str(resp)
def schedule_prompt(params, campaign): """ Prompt the user to schedule calls """ if not params or not campaign: abort(400) resp = VoiceResponse() g = Gather(num_digits=1, timeout=3, method="POST", action=url_for("call.schedule_parse", **params)) existing_schedule = ScheduleCall.query.filter_by(campaign_id=campaign.id, phone_number=params['userPhone']).first() if existing_schedule and existing_schedule.subscribed: play_or_say(g, campaign.audio('msg_alter_schedule'), lang=campaign.language_code) else: play_or_say(g, campaign.audio('msg_prompt_schedule'), lang=campaign.language_code) resp.append(g) # in case the timeout occurs, we need a redirect verb to ensure that the call doesn't drop params['scheduled'] = False resp.redirect(url_for('call._make_calls', **params)) return str(resp)
from twilio.twiml.voice_response import Redirect, VoiceResponse response = VoiceResponse() response.redirect('http://pigeons.com/twiml.xml', method='POST') print(response)
from twilio.twiml.voice_response import Gather, Redirect, VoiceResponse, Say response = VoiceResponse() gather = Gather(action='/process_gather.php', method='GET') gather.say('Enter something, or not') response.append(gather) response.redirect('/process_gather.php?Digits=TIMEOUT', method='GET') print(response)
from twilio.twiml.voice_response import Redirect, VoiceResponse response = VoiceResponse() response.redirect('http://www.foo.com/nextInstructions') print(response)
from twilio.twiml.voice_response import Redirect, VoiceResponse response = VoiceResponse() response.redirect('../nextInstructions') print(response)