当前位置: 首页>>代码示例>>Python>>正文


Python VoiceResponse.append方法代码示例

本文整理汇总了Python中twilio.twiml.voice_response.VoiceResponse.append方法的典型用法代码示例。如果您正苦于以下问题:Python VoiceResponse.append方法的具体用法?Python VoiceResponse.append怎么用?Python VoiceResponse.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twilio.twiml.voice_response.VoiceResponse的用法示例。


在下文中一共展示了VoiceResponse.append方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: conference

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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
开发者ID:rdegges,项目名称:django-twilio,代码行数:27,代码来源:views.py

示例2: voice

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:33,代码来源:example.6.x.py

示例3: test

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
def test(request):
    resp = VoiceResponse()

    gather = Gather(action="/api/v1/ivr/test/route_call/", method="POST", num_digits=1, timeout=10)
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-welcome.mp3")
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-sales.mp3")
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-customer-service.mp3")
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-accounting.mp3")
    resp.append(gather)

    return HttpResponse(resp)
开发者ID:charliephairoj,项目名称:backend,代码行数:13,代码来源:views.py

示例4: voice

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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)
开发者ID:charliephairoj,项目名称:backend,代码行数:18,代码来源:views.py

示例5: generate_connect_conference

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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))
开发者ID:TwilioDevEd,项目名称:warm-transfer-flask,代码行数:10,代码来源:twiml_generator.py

示例6: get_voice_twiml

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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')
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:19,代码来源:response-twiml-client.6.x.py

示例7: intro_wait_human

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
def intro_wait_human(params, campaign):
    """
    Play intro message, and wait for key press to ensure we have a human on the line.
    Then, redirect to _make_calls.
    """
    resp = VoiceResponse()

    play_or_say(resp, campaign.audio('msg_intro'))

    action = url_for("call._make_calls", **params)

    # wait for user keypress, in case we connected to voicemail
    # give up after 10 seconds
    g = Gather(num_digits=1, method="POST", timeout=10, action=action)
    play_or_say(g, campaign.audio('msg_intro_confirm'), lang=campaign.language_code)
    resp.append(g)

    return str(resp)
开发者ID:18mr,项目名称:call-congress,代码行数:20,代码来源:views.py

示例8: call

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
def call():
    """Return TwiML for a moderated conference call."""
    # Start our TwiML response
    response = VoiceResponse()

    # Start with a <Dial> verb
    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)

    response.append(dial)
    return str(response)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:22,代码来源:moderated-conference.6.x.py

示例9: schedule_prompt

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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)
开发者ID:18mr,项目名称:call-congress,代码行数:25,代码来源:views.py

示例10: call

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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))
开发者ID:TwilioDevEd,项目名称:browser-calls-flask,代码行数:17,代码来源:views.py

示例11: VoiceResponse

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
from twilio.twiml.voice_response import Dial, VoiceResponse, Sip

response = VoiceResponse()
dial = Dial()
dial.sip('sip:[email protected]')
response.append(dial)

print(response)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:10,代码来源:sip-1.6.x.py

示例12: VoiceResponse

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:11,代码来源:gather-5.6.x.py

示例13: route_call

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
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)
开发者ID:charliephairoj,项目名称:backend,代码行数:69,代码来源:views.py

示例14: make_single

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import append [as 别名]
def make_single():
    params, campaign = parse_params(request)

    if not params or not campaign:
        abort(400)

    i = int(request.values.get('call_index', 0))
    params['call_index'] = i

    (uid, prefix) = parse_target(params['targetIds'][i])
    (current_target, cached) = Target.get_or_cache_key(uid, prefix)
    if cached:
        # save Target to database
        db.session.add(current_target)
        db.session.commit()

    resp = VoiceResponse()

    if not current_target.number:
        play_or_say(resp, campaign.audio('msg_invalid_location'),
            lang=campaign.language_code)
        return str(resp)

    if current_target.offices:
        if campaign.target_offices == TARGET_OFFICE_DISTRICT:
            office = random.choice(current_target.offices)
            target_phone = office.number
        elif campaign.target_offices == TARGET_OFFICE_BUSY:
            # TODO keep track of which ones we have tried
            undialed_offices = current_target.offices
            # then pick a random one
            office = random.choice(undialed_offices)
            target_phone = office.number
        #elif campaign.target_offices == TARGET_OFFICE_CLOSEST:
        #   office = find_closest(current_target.offices, params['userLocation'])
        #   target_phone = office.phone
        else:
            office = None
            target_phone = current_target.number
    else:
        office = None
        target_phone = current_target.number
        
    play_or_say(resp, campaign.audio('msg_target_intro'),
        title=current_target.title,
        name=current_target.name,
        office_type = office.name if office else '',
        lang=campaign.language_code)

    if current_app.debug:
        current_app.logger.debug(u'Call #{}, {} ({}) from {} in call.make_single()'.format(
            i, current_target.name, target_phone.e164, params['userPhone']))

    try:
        parsed = PhoneNumber(params['userPhone'], params['userCountry'])
        userPhone = parsed.e164
    except phonenumbers.NumberParseException:
        current_app.logger.error('Unable to parse %(userPhone)s for %(userCountry)s' % params)
        # press onward, but we may not be able to actually dial
        userPhone = params['userPhone']

    # sending a twiml.Number to dial init will not nest properly
    # have to add it after creation
    d = Dial(None, caller_id=userPhone,
              time_limit=current_app.config['TWILIO_TIME_LIMIT'],
              timeout=current_app.config['TWILIO_TIMEOUT'], hangup_on_star=True,
              action=url_for('call.complete', **params)) \
        .number(target_phone.e164, sendDigits=target_phone.extension)
    resp.append(d)

    return str(resp)
开发者ID:18mr,项目名称:call-congress,代码行数:73,代码来源:views.py


注:本文中的twilio.twiml.voice_response.VoiceResponse.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。