本文整理汇总了Python中twilio.twiml.voice_response.VoiceResponse类的典型用法代码示例。如果您正苦于以下问题:Python VoiceResponse类的具体用法?Python VoiceResponse怎么用?Python VoiceResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VoiceResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: voice
def voice():
"""Respond to incoming calls with a simple text message."""
resp = VoiceResponse()
resp.say("Hello. It's me.")
resp.play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3")
return str(resp)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:7,代码来源:example-1.6.x.py
示例2: generate_wait
def generate_wait():
twiml_response = VoiceResponse()
wait_message = 'Thank you for calling. Please wait in line for a few seconds. An agent will be with you shortly.'
wait_music = 'http://com.twilio.music.classical.s3.amazonaws.com/BusyStrings.mp3'
twiml_response.say(wait_message)
twiml_response.play(wait_music)
return str(twiml_response)
开发者ID:TwilioDevEd,项目名称:warm-transfer-flask,代码行数:7,代码来源:twiml_generator.py
示例3: verb_view
def verb_view(request):
"""
A simple test view that returns a ``twilio.Verb`` object.
"""
r = VoiceResponse()
r.reject()
return r
开发者ID:rdegges,项目名称:django-twilio,代码行数:7,代码来源:views.py
示例4: incoming_call
def incoming_call(request):
""" Returns TwiML instructions to Twilio's POST requests """
resp = VoiceResponse()
resp.say("For Programmable SMS, press one. For Voice, press any other key.")
resp.gather(numDigits=1, action="/call/enqueue", method="POST")
return HttpResponse(resp)
开发者ID:TwilioDevEd,项目名称:task-router-django,代码行数:7,代码来源:views.py
示例5: conference
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,代码行数:25,代码来源:views.py
示例6: call_status_update_callback
def call_status_update_callback(request):
call_data = request.GET
logger.debug(call_data['employee'])
try:
user = User.objects.get(pk=call_data['employee'])
except Exception as e:
user = User.objects.get(pk=1)
logger.warn(e)
Log.objects.create(type="Call Summary Error (Getting User)",
message=e,
user=user)
try:
call_log = Call.objects.get(twilio_id=call_data.get('ParentCallSid', 0))
except Exception as e:
logger.debug(e)
logger.debug("New Call Created")
call_log = Call()
call_log.twilio_id = request.GET.get(u'ParentCallSid', call_log.twilio_id)
call_log.type = call_log.type or call_data.get('Direction', call_log.type)
call_log.incoming_number = call_log.incoming_number or call_data.get('From', call_log.incoming_number)
call_log.employee = user
call_log.save()
resp = VoiceResponse()
resp.hangup()
return HttpResponse(resp)
开发者ID:charliephairoj,项目名称:backend,代码行数:28,代码来源:views.py
示例7: get_voice_twiml
def get_voice_twiml():
"""Respond to incoming calls with a simple text message."""
resp = VoiceResponse()
resp.say("Thanks for calling!")
return Response(str(resp), mimetype='text/xml')
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:7,代码来源:response-twiml.6.x.py
示例8: generate_connect_conference
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,代码行数:8,代码来源:twiml_generator.py
示例9: voice
def voice():
"""Respond to incoming phone calls with a 'Hello world' message"""
# Start our TwiML response
resp = VoiceResponse()
# Read a message aloud to the caller
resp.say("hello world!", voice='alice')
return str(resp)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:9,代码来源:example.6.x.py
示例10: get_voice_twiml
def get_voice_twiml():
"""Respond to incoming calls with a simple text message."""
resp = VoiceResponse()
if "To" in request.form:
resp.dial(request.form["To"], callerId="+15017250604")
else:
resp.say("Thanks for calling!")
return Response(str(resp), mimetype='text/xml')
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:10,代码来源:response-twiml-dial.6.x.py
示例11: gather
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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:26,代码来源:example.6.x.py
示例12: test
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,代码行数:11,代码来源:views.py
示例13: voice
def voice():
"""Respond to incoming phone calls with a text message."""
# Start our TwiML response
resp = VoiceResponse()
# Read a message aloud to the caller
resp.say("Hello! You will get an SMS message soon.")
# Also tell Twilio to send a text message to the caller
resp.sms("This is the ship that made the Kessel Run in fourteen parsecs?")
return str(resp)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:12,代码来源:example-1.6.x.py
示例14: enqueue
def enqueue(request):
""" Parses a selected product, creating a Task on Task Router Workflow """
resp = VoiceResponse()
digits = request.POST['Digits']
selected_product = 'ProgrammableSMS' if digits == '1' else 'ProgrammableVoice'
task = '{"selected_product": "%s"}' % selected_product
resp.enqueue(None,
workflowSid=WORKSPACE_INFO.workflow_sid,
task=task)
return HttpResponse(resp)
开发者ID:TwilioDevEd,项目名称:task-router-django,代码行数:12,代码来源:views.py
示例15: gatekeeper
def gatekeeper():
logger.info("Call started: %s", request.values)
response = VoiceResponse()
if 'notFirstCall' not in request.values:
# Accept Google voice call
response.play(digits='1')
add_gandalf_to_response(response)
return str(response)
开发者ID:jfly,项目名称:gatekeeper,代码行数:12,代码来源:routes.py
示例16: post_valid
def post_valid(self, request):
"""Expects a POST request from Twilio, and return a response directing
Twilio to play the greeting mp3 and post the recorded response to
the handle voicemail URL
"""
response = VoiceResponse()
self.static_greeting_path = static(self.voicemail_static_path)
self.record_voicemail_url = request.build_absolute_uri(
reverse('phone-handle_new_message')).replace('http:', 'https:')
response.play(self.static_greeting_path)
response.record(action=self.record_voicemail_url, method='POST')
return HttpResponse(response)
开发者ID:codeforamerica,项目名称:intake,代码行数:12,代码来源:views.py
示例17: complete
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)
开发者ID:18mr,项目名称:call-congress,代码行数:52,代码来源:views.py
示例18: outbound
def outbound():
response = VoiceResponse()
response.say("Thank you for contacting our sales department. If this "
"click to call application was in production, we would "
"dial out to your sales team with the Dial verb.",
voice='alice')
'''
# Uncomment this code and replace the number with the number you want
# your customers to call.
response.number("+16518675309")
'''
return str(response)
开发者ID:TwilioDevEd,项目名称:clicktocall-flask,代码行数:13,代码来源:app.py
示例19: voice
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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:14,代码来源:example.6.x.py
示例20: call
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,代码行数:15,代码来源:views.py
注:本文中的twilio.twiml.voice_response.VoiceResponse类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论