def test_sip(self): """ should redirect the call """ d = Dial() d.sip('*****@*****.**') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sip>[email protected]</Sip></Dial></Response>' )
def test_sip_username_password(self): """ should redirect the call """ d = Dial() d.sip('*****@*****.**', username='******', password='******') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sip password="******" username="******">[email protected]</Sip></Dial></Response>' )
def generate_call_agent(from_, agent_id, callback_url, is_sip=False): account_sid = ENV['TWILIO_ACCOUNT_SID'] auth_token = ENV['TWILIO_AUTH_TOKEN'] my_number = ENV['TWILIO_NUMBER'] #from_ = my_number #from_ = my_number if 'sip:' in from_: from_numbers = from_.split(':')[1] from_ = from_numbers.split('@')[0] twiml_response = VoiceResponse() dial = Dial(caller_id=from_) if is_sip: dial.sip(agent_id) else: dial.number(agent_id) twiml_response.append(dial) res = str(twiml_response) print res return res
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.sip('sip:[email protected]') response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.sip('sip:[email protected]', 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 Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.sip('*****@*****.**', username='******', password='******') response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.sip('*****@*****.**') response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial(record='record-from-answer', timeout=10, hangup_on_star=True, caller_id='bob', method='POST', action='/handle_post_dial') dial.sip('sip:[email protected]?x-customheader=foo', method='POST', url='/handle_screening_on_answer') response.append(dial) print(response)
def makeCall(): to = request.values.get("to") To = request.values.get("To") From = request.values.get("From") resp = VoiceResponse() myDomain = '@william.sip.us1.twilio.com' if From.startswith('sip:0001'): To = To.split(':0989', 1)[1].split('@', 1)[0] if To == '0002': dial = Dial(caller_id='0001') destination = To + '@william.sip.us1.twilio.com' resp.say( "Cool! David You have just made call from 3CX sip domain to 0002 sip domain!" ) dial.sip(destination) resp.append(dial) else: resp.say( "Cool! Kevin You have just made call from 3CX sip domain to mobile APP!" ) resp.dial(callerId=CALLER_ID).client(To) elif From.startswith('sip:0002'): To = To.split(':', 1)[1].split('@', 1)[0] if To == '0001': dial = Dial(caller_id='0002') destination = To + '@william.sip.us1.twilio.com' resp.say( "Cool! Hellen You have just made call from sip domain to sip domain!" ) dial.sip(destination) resp.append(dial) else: resp.say( "Cool! Stary You have just made call from sip domain to mobile APP!" ) print(To) resp.dial(callerId=CALLER_ID).client(To) elif From.startswith('client:'): dial = Dial(caller_id=IDENTITY) if to == '0001' or to == '0002': destination = to + '@william.sip.us1.twilio.com' resp.say( "Congratulations! Peter You have just made call from mobile APP to sip domain!" ) dial.sip(destination) resp.append(dial) else: resp.say( "Congratulations! Victor You have just made call from mobile APP! to mobile APP!" ) resp.dial(callerId=CALLER_ID).client(to) else: resp.say("Oh No! Something wrong") print(resp) return str(resp)
from twilio.twiml.voice_response import Dial, Number, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.number('+12143211432') dial.sip('sip:[email protected]') dial.sip('sip:[email protected]') dial.sip('sip:[email protected]') response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial(answer_on_bridge=True, refer_url='https://example.com/handler') dial.sip( 'sip:[email protected]?User-to-User=123456789%3Bencoding%3Dhex&X-Name=Agent%2C+A' ) response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.sip('sip:[email protected]?mycustomheader=foo&myotherheader=bar') response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.sip('sip:[email protected];transport=tcp') response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial() dial.sip('sip:[email protected]?x-mycustomheader=foo&x-myotherheader=bar') response.append(dial) print(response)
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip response = VoiceResponse() dial = Dial( record='record-from-answer', timeout=10, hangup_on_star=True, caller_id='bob', method='POST', action='/handle_post_dial' ) dial.sip( 'sip:[email protected]?customheader=foo', method='POST', url='/handle_screening_on_answer' ) response.append(dial) print(response)