def test_add_client(self): """ add a client to a dial """ d = Dial() d.client('alice') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client>alice</Client></Dial></Response>' )
def generate_twilio_client_response(self, client, ring_tone='at'): """Generates voice call instructions to forward the call to agents computer. """ resp = VoiceResponse() dial = Dial( ring_tone=ring_tone, record=self.settings.record_calls, recording_status_callback=self.get_recording_status_callback_url(), recording_status_callback_event='completed') dial.client(client) resp.append(dial) return resp
def call(request): """Returns TwiML instructions to Twilio's POST requests""" response = Dial(caller_id=settings.TWILIO_NUMBER) # If the browser sent a phoneNumber param, we know this request # is a support agent trying to call a customer's phone if 'phoneNumber' in request.POST: response.number(request.POST['phoneNumber']) else: # Otherwise we assume this request is a customer trying # to contact support from the home page response.client('support_agent') return HttpResponse(str(response))
def voice(): resp = VoiceResponse() if "To" in request.form and request.form["To"] != '': dial = Dial(caller_id=os.environ['TWILIO_CALLER_ID']) # wrap the phone number or client name in the appropriate TwiML verb # by checking if the number given has only digits and format symbols if phone_pattern.match(request.form["To"]): dial.number(request.form["To"]) else: dial.client(request.form["To"]) resp.append(dial) else: resp.say("Thanks for calling!") return Response(str(resp), mimetype='text/xml')
def call(): p.pprint(request.form) response = VoiceResponse() dial = Dial(callerId=twilio_number) if 'To' in request.form and request.form['To'] != twilio_number: print('outbound call') dial.number(request.form['To']) else: print('incoming call') caller = request.form['Caller'] dial = Dial(callerId=caller) dial.client(twilio_number) return str(response.append(dial))
def call(): """Returns TwiML instructions to Twilio's POST requests""" response = VoiceResponse() dial = Dial(callerId=app.config['TWILIO_NUMBER']) # If the browser sent a phoneNumber param, we know this request # is a support agent trying to call a customer's phone if 'phoneNumber' in request.form: dial.number(request.form['phoneNumber']) else: # Otherwise we assume this request is a customer trying # to contact support from the home page dial.client('support_agent') return str(response.append(dial))
def call(): """Returns TwiML instructions to Twilio's POST requests""" response = VoiceResponse() dial = Dial(callerId=app.config['TWILIO_NUMBER']) # If the browser sent a phoneNumber param, we know this request # is a support agent trying to call a customer's phone if 'phoneNumber' in request.form: dial.number(request.form['phoneNumber']) else: # Otherwise we assume this request is a customer trying # to contact support from the home page dial.client('support_agent') return str(response.append(dial))
def voice(request): """Returns TwiML instructions to Twilio's POST requests""" resp = VoiceResponse() dial = Dial(caller_id='+6625088681') # If the browser sent a phoneNumber param, we know this request # is a support agent trying to call a customer's phone if 'phoneNumber' in request.POST: dial.number(request.POST['phoneNumber']) else: # Otherwise we assume this request is a customer trying # to contact support from the home page dial.client('support_agent') resp.append(dial) return HttpResponse(resp)
def get_voice_twiml(): """Respond to incoming calls with a simple text message.""" resp = VoiceResponse() if "To" in request.form: dial = Dial(callerId="+15017122661") # wrap the phone number or client name in the appropriate TwiML verb # by checking if the number given has only digits and format symbols if phone_pattern.match(request.form["To"]): dial.number(request.form["To"]) else: dial.client(request.form["To"]) resp.append(dial) else: resp.say("Thanks for calling!") return Response(str(resp), mimetype='text/xml')
def get_voice_twiml(): """Respond to incoming calls with a simple text message.""" resp = VoiceResponse() if "To" in request.form: dial = Dial(callerId="+15017250604") # wrap the phone number or client name in the appropriate TwiML verb # by checking if the number given has only digits and format symbols if phone_pattern.match(request.form["To"]): dial.number(request.form["To"]) else: dial.client(request.form["To"]) resp.append(dial) else: resp.say("Thanks for calling!") return Response(str(resp), mimetype='text/xml')
def voice(): resp = VoiceResponse() add_ons = json.loads(request.values['AddOns']) if "To" in request.form and request.form["To"] != '': dial = Dial( caller_id=os.environ['TWILIO_CALLER_ID'], record='record-from-answer-dual', recording_status_callback='insertURL' ) # wrap the phone number or client name in the appropriate TwiML verb # by checking if the number given has only digits and format symbols if phone_pattern.match(request.form["To"]): dial.number(request.form["To"]) else: dial.client(request.form["To"]) resp.append(dial) else: resp.say("Thanks for calling!") return Response(str(resp), mimetype='text/xml')
from twilio.twiml.voice_response import Client, Dial, Number, VoiceResponse response = VoiceResponse() dial = Dial(caller_id='+1888XXXXXXX') dial.number('858-987-6543') dial.client('joey') dial.client('charlie') response.append(dial) print(response)
from twilio.twiml.voice_response import Client, Dial, VoiceResponse response = VoiceResponse() dial = Dial() dial.client('jenny') response.append(dial) print(response)
from twilio.twiml.voice_response import Client, Dial, VoiceResponse response = VoiceResponse() dial = Dial() dial.client( 'jenny', status_callback_event='initiated ringing answered completed', status_callback='https://myapp.com/calls/events', status_callback_method='POST' ) response.append(dial) print(response)
from twilio.twiml.voice_response import Client, Dial, VoiceResponse response = VoiceResponse() dial = Dial() dial.client('joey') response.append(dial) print(response)
def route_call(request): digits = int(request.POST.get('Digits', '0')) call_origin = request.POST.get('From', None) call_log = Call.objects.create(twilio_id=request.POST.get('CallSid', None), type="incoming", incoming_number=call_origin) if digits == 1: message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-sales.mp3" numbers = [(73, '+66819189145')] clients = [(73, "sidarat")] caller_id = call_origin or '+6625088681' call_log.forwarding_number = '+66819189145' call_log.save() elif digits == 2: message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-customer-service.mp3" numbers = [(16, '+66914928558'), (42, '+66952471426'), (42, '+66634646465')] clients = [(16, "chup"), (42, 'apaporn')] caller_id = '+6625088681' elif digits == 3: message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-accounting.mp3" numbers = [(63, '+66988325610')] clients = [(63, "mays")] caller_id = '+6625088681' elif digits == 8: message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-accounting.mp3" numbers = [(1, '+66990041468')] clients = [(1, "charliephairoj")] caller_id = "+6625088681" call_log.forwarding_number = '+66990041468' call_log.save() else: message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-customer-service.mp3" numbers = [(16, '+66914928558'), (42, '+66952471426')] clients = [(16, "chup"), (42, 'apaporn')] caller_id = '+6625088681' or '+6625088681' resp = VoiceResponse() resp.play(message) dial = Dial(caller_id=caller_id, record='record-from-ringing', recording_status_callback="/api/v1/ivr/recording/") for number in numbers: dial.number(number[1], status_callback_event='answered completed', status_callback=_get_status_callback_url(number[0]), status_callback_method="GET") for client in clients: dial.client(client[1], status_callback_event='answered completed', status_callback=_get_status_callback_url(client[0]), status_callback_method="GET") resp.append(dial) return HttpResponse(resp)
from twilio.twiml.voice_response import Client, Dial, VoiceResponse response = VoiceResponse() dial = Dial() dial.client('joey', status_callback_event='initiated ringing answered completed', status_callback='https://myapp.com/calls/events', status_callback_method='POST') response.append(dial) print(response)