Esempio n. 1
0
def conference(request, name, muted=None, beep=None,
               start_conference_on_enter=None, end_conference_on_exit=None,
               wait_url=None, wait_method='POST', max_participants=None):
    """
See: http://www.twilio.com/docs/api/twiml/conference.

Usage::

    # urls.py
    urlpatterns = patterns('',
        # ...
        url(r'^conference/(?P<name>\w+)/$', 'django_twilio.views.conference',
                {'max_participants': 10}),
        # ...
    )
    """
    r = VoiceResponse()
    dial = Dial()
    dial.conference(name=name, muted=muted, beep=beep,
                    startConferenceOnEnter=start_conference_on_enter,
                    endConferenceOnExit=end_conference_on_exit,
                    waitUrl=wait_url, waitMethod=wait_method,
                    )
    r.append(dial)
    return r
def generate_connect_conference(call_sid, wait_url, start_on_enter, end_on_exit):
    twiml_response = VoiceResponse()
    dial = Dial()
    dial.conference(call_sid,
                    start_conference_on_enter=start_on_enter,
                    end_conference_on_exit=end_on_exit,
                    wait_url=wait_url)
    return str(twiml_response.append(dial))
def generate_connect_conference(call_sid, wait_url, start_on_enter,
                                end_on_exit):
    twiml_response = VoiceResponse()
    dial = Dial()
    dial.conference(call_sid,
                    start_conference_on_enter=start_on_enter,
                    end_conference_on_exit=end_on_exit,
                    wait_url=wait_url)
    res = str(twiml_response.append(dial))
    print 'generate_connect_conference'
    print res
    return res
    def test_add_conference(self):
        """ add a conference to a dial """
        d = Dial()
        d.conference('My Room')

        r = VoiceResponse()
        r.append(d)

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference>My Room</Conference></Dial></Response>'
        )
    def test_add_number(self):
        """ add a number to a dial """
        d = Dial()
        d.number('1231231234')

        r = VoiceResponse()
        r.append(d)

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number>1231231234</Number></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 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>'
        )
Esempio n. 8
0
def voice():
    speech_reponse_url = url_for(
        'intercom.speech_response', _external=True, _scheme='https')
    print(speech_reponse_url)
    intercom_welcome_url = url_for(
        'intercom.recording', values='welcome', _external=True, _scheme='https')
    response = VoiceResponse()
    with response.gather(action=speech_reponse_url, input='speech', speechTimeout='1') as gather:
        gather.play(intercom_welcome_url)
    dial = Dial()
    dial.dial(os.environ["TENANT_PHONE_NUMBER"])
    response.append(dial)
    return twiml(response)
Esempio n. 9
0
	def generate_twilio_dial_response(self, from_number: str, to_number: str):
		"""Generates voice call instructions to forward the call to agents Phone.
		"""
		resp = VoiceResponse()
		dial = Dial(
			caller_id=from_number,
			record=self.settings.record_calls,
			recording_status_callback=self.get_recording_status_callback_url(),
			recording_status_callback_event='completed'
		)
		dial.number(to_number)
		resp.append(dial)
		return resp
Esempio n. 10
0
	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
Esempio n. 11
0
    def test_add_number_status_callback_event(self):
        """ add a number to a dial with status callback events"""
        d = Dial()
        d.number('1231231234',
                 status_callback='http://example.com',
                 status_callback_event='initiated completed')

        r = VoiceResponse()
        r.append(d)

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number statusCallback="http://example.com" statusCallbackEvent="initiated completed">1231231234</Number></Dial></Response>'
        )
Esempio n. 12
0
    def generate_twilio_dial_response(self, from_number: str, to_number: str):
        """Generates voice call instructions needed for twilio.
		"""
        url_path = "/api/method/twilio_integration.twilio_integration.api.update_recording_info"
        recording_status_callback = get_public_url(url_path)

        resp = VoiceResponse()
        dial = Dial(caller_id=from_number,
                    record=self.settings.record_calls,
                    recording_status_callback=recording_status_callback,
                    recording_status_callback_event='completed')
        dial.number(to_number)
        resp.append(dial)
        return resp
Esempio n. 13
0
def my_conference_line(request):
    response = VoiceResponse()
    dial = Dial()

    target_number = config('TARGET_NUMBER')
    number = Number(target_number)

    response.say(
        'Thank you for allowing TireTutor to make tire buying easier ' +
        'for you! Please wait while we connect you to your tire dealer now!')
    dial.number(target_number, url=CALL_WHISPER_URL, method='GET')
    response.append(dial)

    return HttpResponse(str(response))
Esempio n. 14
0
def whisper():

    response = VoiceResponse()
    dial = Dial()

    dial.conference('AgentConference',
                    beep=False,
                    coach=agent_sid,
                    status_callback="/statuscallback",
                    status_callback_event="start end join leave mute hold")

    response.append(dial)

    return str(response)
Esempio n. 15
0
def call():
    numbers = ['720-938-7168', '774-232-6921', '513-675-5664', '310-502-9285']
    response = VoiceResponse()
    caller = request.values['From']
    if not validateNumber(caller):
        response.reject()
    else:
        response.say('Thank you for calling LikeWallet!  Please remain on the line and the next available representative will assist you.', voice='woman', language='en')
        dial = Dial()
        for number in numbers:
            dial.number(number)
            response.append(dial)

    return str(response)
Esempio n. 16
0
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))
Esempio n. 17
0
    def test_conference(self):
        d = Dial()
        d.conference('TestConferenceAttributes',
                     beep=False,
                     wait_url='',
                     start_conference_on_enter=True,
                     end_conference_on_exit=True)

        r = VoiceResponse()
        r.append(d)

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference beep="false" endConferenceOnExit="true" startConferenceOnEnter="true" waitUrl="">TestConferenceAttributes</Conference></Dial></Response>'
        )
Esempio n. 18
0
def inbound_call():
    response = VoiceResponse()
    with Dial() as dial:
        if request.values.get('From') == Moderator:
            global agent_sid

            agent_sid = request.values.get('CallSid')
            print(agent_sid + ' is the agent sid')
            dial.conference(
                'AgentConference',
                status_callback="/statuscallback",
                status_callback_event="start end join leave mute hold")
        else:
            global customer_sid
            customer_sid = request.values.get('CallSid')
            print(customer_sid + ' is the customer sid')
            dial.conference(
                'AgentConference',
                wait_url="/hold_message",
                end_conference_on_exit=True,
                status_callback="/statuscallback",
                status_callback_event="start end join leave mute hold")

    response.append(dial)

    return str(response)
Esempio n. 19
0
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="+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')
Esempio n. 21
0
def routedDialer(*args, **kwargs):
    sipFrom = numberFromSip.match(kwargs['caller_id'])
    if sipFrom and sipFrom.group('domain') in domains:
        if sipFrom.group('user') in users:
            kwargs['caller_id'] = users[sipFrom.group('user')]
        elif sipFrom.group('number') in numbers:
            kwargs['caller_id'] = sipFrom.group('number')
    elif sipFrom:
        del kwargs['caller_id']
    return Dial(*args, **kwargs)
Esempio n. 22
0
def twilio_call(matrix_id):
    twilio_client = util.getTwilioClient(matrix_id)
    direction = request.values['Direction']
    to_number = request.values['To']
    from_number = request.values['From']
    call_status = request.values["CallStatus"]
    forwarded_from = request.values.get("ForwardedFrom", None)
    json_config = util.getIncomingNumberConfig(matrix_id, to_number)
    url = util.getAppserviceAddress().rstrip('/') + urllib.parse.urlparse(request.url).path
    response = VoiceResponse()
    if direction == 'inbound':
        from_hunt_number = False
        for entry in json_config["hunt_numbers"]:
            if entry[0] == from_number or entry[0] == forwarded_from:
                from_hunt_number = True
                matching_hunt_number = entry[0]
                break

        loop_detected = False
        if from_hunt_number:
            ringing_calls = twilio_client.calls.list(status="ringing",to=matching_hunt_number,limit=2)
            queued_calls = twilio_client.calls.list(status="queued",to=matching_hunt_number,limit=2)
            for call in ringing_calls + queued_calls:
                loop_detected = True
                parent_call = twilio_client.calls(call.parent_call_sid).fetch()
                parent_call.update(url=util.adjustUrl(url,"voicemail-no-notify"))

        if json_config["hunt_enabled"] and not from_hunt_number:
            dial = Dial(action = util.adjustUrl(url,"voicemail"),timeout=json_config["hunt_timeout"],answerOnBridge=True)
            for pair in json_config["hunt_numbers"]:
                if pair[2] == "":
                    url = util.getAppserviceAddress() + "/twilio/check-accept"
                elif pair[2] == "key":
                    url = util.getAppserviceAddress() + "/twilio/check-key"
                elif pair[2] == "speech":
                    url = util.getAppserviceAddress() + "/twilio/check-speech"
                dial.number(pair[0], send_digits=pair[1], url=url)
            response.append(dial)
        elif not loop_detected:
            return twilio_voicemail(True)
        else:
            response.reject()
    return str(response)
Esempio n. 23
0
def voice():
    """Respond to incoming phone calls with a menu of options"""
    pprint(request.values)  # kept for debugging purposes
    resp = VoiceResponse()
    agent = AGENTS.get(request.values.get("Caller"))

    if "Digits" in request.values:
        choice = request.values["Digits"]

        if agent:
            if choice == "1":
                resp.say("You will get the next call.")
                dial = Dial()
                dial.queue(call_queue.name)
                resp.append(dial)
            else:
                resp.say("Sorry, I don't understand that choice.")
    else:
        queue_size = call_queue.size()
        if agent:
            gather = Gather(num_digits=1)
            gather.say(
                f"Hello, {agent}. There are {queue_size} callers in the queue, press 1 to answer the next call"
            )
            resp.append(gather)
        else:
            # customer
            resp.say(
                f"There are {queue_size} people ahead of you. An agent will talk to you soon."
            )

            # in case you want to play a message before
            # resp.play(
            #    'http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3'
            # )

            resp.enqueue(call_queue.name)
            # wait_url = 'http://demo.twilio.com/docs/voice.xml'

    # If the caller doesn't select an option, redirect them into a loop
    resp.redirect("/voice")
    return str(resp)
Esempio n. 24
0
def bridge():
    ptoken = request.args['ptoken']
    pprint.pprint(request.form)
    answeredBy = request.args.get('AnsweredBy') or request.form.get(
        'AnsweredBy')
    print(answeredBy)
    response = VoiceResponse()
    if answeredBy in ("human", "unknown"):
        response.play("%s/media/welcome_please_wait.mp3" %
                      config.WEB_DOMAIN_PROD,
                      action="/dialstatus")
        dial = Dial()
        dial.conference(ptoken,
                        waitUrl="%s/media/ttv_hold_music.mp3" %
                        config.WEB_DOMAIN_PROD,
                        waitMethod="GET")
        response.append(dial)
    else:
        response.hangup()
    return Response(str(response), mimetype='text/xml')
Esempio n. 25
0
def handle_key(request):
    """Handle key press from a user."""

    # Get the digit pressed by the user
    digit_pressed = request.POST.get('Digits', '')
    if digit_pressed == "1":

        resp = VoiceResponse()
        dial = Dial()
        dial.number('516-640-7250')
        resp.append(dial)

        return HttpResponse(str(resp))

    elif digit_pressed == "2":

        resp = VoiceResponse()
        resp.say("Record your message after the tone.")
        resp.record(maxLength="30", action="/phone/ring/handle_recording/")
        return HttpResponse(str(resp))
Esempio n. 26
0
def join_conference():
    for key in request.form:
        pprint(key)
    account_sid = request.form['AccountSid']
    user = User.query.filter_by(twilio_account_sid=account_sid).first()
    response = VoiceResponse()
    dial = Dial()
    if user:
        greeting = response.say(
            'You are entering {}\'s Conference Room'.format(user.first_name))
    dial.conference(
        'The Marae',
        status_callback=url_for('main.parse_events', _external=True),
        status_callback_event='start end join leave mute hold speaker',
        record='record-from-start',
        recording_status_callback=url_for('main.recording_events',
                                          _external=True))
    response.append(dial)
    pprint(str(response))
    return str(response)
Esempio n. 27
0
def initialCall(To, conference_name):
    if conference_name in LANGUAGE_LIST:

        if 'delay' in conference_name:
            group_status = conferenceStatus['delay']
        else:
            group_status = conferenceStatus['live']

        if group_status == 'off-air':
            return str(group_is_closed())

        response = VoiceResponse()
        dial = Dial()
        dial.conference(muted=True,
                        beep=False,
                        end_conference_on_exit=False,
                        start_conference_on_enter=False,
                        max_participants=250,
                        trim="do-not-trim",
                        wait_url="/conference/onHold",
                        wait_method="GET",
                        name=conference_name)
        response.append(dial)

        return str(response)
    print('To: {}'.format(To))
    group = get_group_by_did(To)
    # print(group)
    if group:
        print(get_conference_status_by_group(group))
        if get_conference_status_by_group(group) == 'on-air':
            response = VoiceResponse()
            gather = Gather(action="/conference/gatherDigit",
                            method="GET",
                            num_digits=1,
                            timeout=30)
            gather.play(group['ivr_audio'])
            response.append(gather)
            return str(response)

    return str(group_is_closed())
Esempio n. 28
0
def call():
    """Returns TwiML instructions to Twilio's POST requests"""
    response = VoiceResponse()
    number = ""
    zipCode = ""
    dict = request.form
    for value in dict:
        if dict[value].startswith('number'):
            number = dict[value].split(":")[-1]
        if dict[value].startswith('zipCode'):
            zipCode = dict[value].split(":")[-1]
    phone_number = number  # or default_client
    zip_code = zipCode
    print(phone_number)
    print(zip_code)
    # undecoded_phone = number
    # base64_bytes = undecoded_phone.encode('ascii')
    # message_bytes = base64.b64decode(base64_bytes)
    # phone_number = str(decrypt(message_bytes, FERNET_KEY)).replace("b'","").replace("'","")
    dial = Dial(callerId=NUMBERS_OUTBOUND)
    try:
        dial.number(numberVerify(zip_code, phone_number)['number'])
    except:
        dial.number(NUMBERS_OUTBOUND)
    return str(response.append(dial))
Esempio n. 29
0
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 join_conference(caller, resp):
    with Dial() as dial:
        # If the caller is our MODERATOR, then start the conference when they
        # join and end the conference when they leave
        if request.values.get('From') == MODERATOR:
            dial.conference('My conference',
                            start_conference_on_enter=True,
                            end_conference_on_exit=True)
        else:
            # Otherwise have the caller join as a regular participant
            dial.conference('My conference', start_conference_on_enter=False)

        resp.append(dial)
        return str(resp)
Esempio n. 31
0
def codecConference(From):
    conference_name = match("sip:(.*)@.*", From).group(1)

    if 'delay' in conference_name:
        group_status = conferenceStatus['delay']
    else:
        group_status = conferenceStatus['live']

    if group_status == 'off-air':
        return str(group_is_closed())

    response = VoiceResponse()
    dial = Dial()
    dial.conference(muted=False,
                    beep=False,
                    end_conference_on_exit=False,
                    start_conference_on_enter=True,
                    max_participants=250,
                    trim="do-not-trim",
                    name=conference_name)
    response.append(dial)

    return str(response)
Esempio n. 32
0
def conf_call():
    response = VoiceResponse()
    with Dial() as dial:
        if request.values.get('From') == MODERATOR:
            dial.conference(
                "My Conference Room",
                start_conference_on_enter=True,
                end_conference_on_exit=True,
                waitUrl="http://twimlets.com/holdmusic?Bucket=com.twilio.music.electronica&amp;Message=please%20wait",
            )
        else:
            dial.conference('My Conference Room', start_conference_on_enter=False)
    response.append(dial)
    return str(response)
Esempio n. 33
0
def conference(request,
               name,
               muted=None,
               beep=None,
               start_conference_on_enter=None,
               end_conference_on_exit=None,
               wait_url=None,
               wait_method='POST',
               max_participants=None):
    """
    See: http://www.twilio.com/docs/api/twiml/conference.
    """
    # Usage::
    #
    #     # urls.py
    #     urlpatterns = patterns('',
    #         # ...
    #         url(r'^conference/(?P<name>\w+)/$',
    #             'django_twilio.views.conference',
    #              {'max_participants': 10}
    #         ),
    #         # ...
    #     )
    #
    r = VoiceResponse()
    dial = Dial()
    dial.conference(
        name=name,
        muted=muted,
        beep=beep,
        startConferenceOnEnter=start_conference_on_enter,
        endConferenceOnExit=end_conference_on_exit,
        waitUrl=wait_url,
        waitMethod=wait_method,
    )
    r.append(dial)
    return r
Esempio n. 34
0
def join_conference(caller, resp):
    with Dial() as dial:
        # If the caller is our MODERATOR, then start the conference when they
        # join and end the conference when they leave
        # if any([x for x in programs if 'new york' in x.lower()] from https://stackoverflow.com/questions/10484261/find-dictionary-items-whose-key-matches-a-substring

        if any([caller[4:] in MODERATOR]):
            dial.conference('My conference',
                            start_conference_on_enter=True,
                            end_conference_on_exit=True)
        else:
            # Otherwise have the caller join as a regular participant
            dial.conference('My conference', start_conference_on_enter=False)

        resp.append(dial)
        return str(resp)
Esempio n. 35
0
def perform_call(number, caller_id=None):
    response = VoiceResponse()
    d = Dial()
    if number == PRIVATE_NUMBER:
        p = Play("http://phone.ehnerd.com/music/intro.wav")
        response.append(p)
        d.number(number, url="/callscreen")
    else:
        d.number(number)
    response.append(d)
    return str(response)
Esempio n. 36
0
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)
Esempio n. 37
0
from twilio.twiml.voice_response import Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial(
    record='record-from-ringing-dual',
    recording_status_callback='www.myexample.com'
)
dial.conference('myteamroom')
response.append(dial)

print(response)
Esempio n. 38
0
from twilio.twiml.voice_response import Dial, Number, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.number('415-123-4567')
response.append(dial)

print(response)
from twilio.twiml.voice_response import Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference('Customer Waiting Room', beep=False)
response.append(dial)

print(response)
Esempio n. 40
0
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 Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial(
    action='handleLeaveConference.php',
    method='POST',
    hangup_on_star=True,
    time_limit=30
)
dial.conference('LoveTwilio')
response.append(dial)

print(response)
Esempio n. 42
0
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)
Esempio n. 43
0
from twilio.twiml.voice_response import Dial, Number, VoiceResponse

response = VoiceResponse()
dial = Dial(caller_id='+15551112222')
dial.number('+15558675309')
response.append(dial)

print(response)
from twilio.twiml.voice_response import Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference('SimpleRoom', muted=True)
response.append(dial)

print(response)
Esempio n. 45
0
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)
Esempio n. 46
0
from twilio.twiml.voice_response import Dial, VoiceResponse, Sim

response = VoiceResponse()
dial = Dial(record='record-from-ringing')
dial.sim('DE8caa2afb9d5279926619c458dc7098a8')
response.append(dial)

print(response)
from twilio.twiml.voice_response import Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference('Room 1234')
response.append(dial)

print(response)
Esempio n. 48
0
from twilio.twiml.voice_response import Client, Dial, Number, VoiceResponse

response = VoiceResponse()
dial = Dial(caller_id='+1888XXXXXXX')
dial.number('858-987-6543')
dial.client('jenny')
dial.client('tommy')
response.append(dial)

print(response)
Esempio n. 49
0
from twilio.twiml.voice_response import Dial, Number, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.number('858-987-6543')
dial.number('415-123-4567')
dial.number('619-765-4321')
response.append(dial)

print(response)
from twilio.twiml.voice_response import Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference('moderated-conference-room', start_conference_on_enter=False)
response.append(dial)

print(response)
Esempio n. 51
0
from twilio.twiml.voice_response import Dial, Number, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.number('415-123-4567', send_digits='wwww1928')
response.append(dial)

print(response)
from twilio.twiml.voice_response import Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference(
    'NoMusicNoBeepRoom',
    beep=False,
    wait_url='http://your-webhook-host.com',
    start_conference_on_enter=True,
    end_conference_on_exit=True
)
response.append(dial)

print(response)
Esempio n. 53
0
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 Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference(
    'Customer Waiting Room', beep=False, end_conference_on_exit=True
)
response.append(dial)

print(response)
from twilio.twiml.voice_response import Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference(
    'EventedConf',
    status_callback='https://myapp.com/events',
    status_callback_event='start end join leave mute hold'
)
response.append(dial)

print(response)
Esempio n. 56
0
from twilio.twiml.voice_response import Dial, Number, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.number(
    '+14155555555',
    status_callback_event='initiated ringing answered completed',
    status_callback='https://myapp.com/calls/events',
    status_callback_method='POST'
)
dial.number(
    '+14153333333',
    status_callback_event='initiated ringing answered completed',
    status_callback='https://example.com/events',
    status_callback_method='POST'
)
response.append(dial)

print(response)
Esempio n. 57
0
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip

response = VoiceResponse()
dial = Dial()
dial.sip('*****@*****.**', username='******', password='******')
response.append(dial)

print(response)
Esempio n. 58
0
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)
Esempio n. 59
0
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 Conference, Dial, VoiceResponse

response = VoiceResponse()
dial = Dial()
dial.conference(
    'moderated-conference-room',
    start_conference_on_enter=True,
    end_conference_on_exit=True
)
response.append(dial)

print(response)