def enqueue_call(request): resp = VoiceResponse() resp.enqueue( None, workflowSid=settings.TWILIO_WORKFLOW_SID, wait_url="https://helpingagents.herokuapp.com/api/webhooks/enqueue-wait-url/", ) return HttpResponse(str(resp), content_type="application/xml")
def key_handle(): digitPressed = request.form['Digits'] resp = VoiceResponse() if digitPressed == "1": resp.redirect("/voicemail-handle") return str(resp) elif digitPressed != "1": resp.enqueue("Hold Queue", wait_url="/callQ-handle") return str(resp)
def key_handle(): digitPressed = request.values.get('Digits', None) if digitPressed == "1": resp = VoiceResponse() resp.redirect("/voicemail-handle") return str(resp) elif digitPressed != "1": resp = VoiceResponse() resp.enqueue("Hold Queue", wait_url="/hold-handle", waitUrlMethod='GET') return str(resp)
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)
def test_enqueue(self): r = VoiceResponse() r.enqueue('TestEnqueueAttribute', action='act', method='GET', wait_url='wait', wait_url_method='POST') assert_equal( self.strip(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue action="act" method="GET" waitUrl="wait" waitUrlMethod="POST">TestEnqueueAttribute</Enqueue></Response>' )
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)
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': selected_product} enqueue = resp.enqueue(None, workflowSid=WORKSPACE_INFO.workflow_sid) enqueue.task(json.dumps(task)) return HttpResponse(resp)
def enqueue_call(): digit_pressed = request.values.get('Digits') if digit_pressed == "2" : want_text = False else: want_text = True resp = VoiceResponse() enqueue = resp.enqueue(None, workflow_sid=workflow_sid) enqueue.task('{"want_text":"' + str(want_text) +'"}') resp.append(enqueue) return str(resp)
def enqueue_to_flex(): caller = request.args.get('Caller') formatted_caller = caller[1:] print(formatted_caller) location = fetch_sync_data(formatted_caller) print(location) resp = VoiceResponse() enqueue = resp.enqueue( None, workflow_sid='WW753b6e8c074d797802e6e68cc823b74d') enqueue.task(json.dumps( {'type': 'inbound', 'name': caller, 'lat': location['lat'], 'lng': location['lng']})) resp.append(enqueue) return str(resp)
def handle_input(): if 'Digits' in request.values: choice = int(request.values['Digits']) dept = {1: "sales", 2: "support", 3: "billing"} resp = VoiceResponse() with resp.enqueue(workflow_sid=workflow_sid) as e: e.task('{"selected_product" : "' + dept[choice] + '"}') else: resp = VoiceResponse() resp.say("No digits detected") resp.redirect('/incoming_call') return Response(str(resp), mimetype='text/xml')
def enqueue_call(): if 'Digits' in request.values: digit_pressed = request.values['Digits'] workflow_d = return_work_space( digit_pressed) #array of workspace and product resp = VoiceResponse() select_lang = request.values['lang'] with resp.enqueue(None, workflow_Sid=workflow_d[0]) as e: e.task('{"selected_language" : "' + select_lang + '", "selected_product" : "' + workflow_d[1] + '"}') return Response(str(resp), mimetype='text/xml') else: resp = VoiceResponse() resp.say("no digits detected") #tell user something is amiss resp.redirect("/incoming_call") #redirect back to initial step return Response(str(resp), mimetype='text/xml')
def post(self, request, *args, **kwargs): logger.info(f'Voice Enqueue POST received: {json.dumps(request.data)}') digit_pressed = int(request.data.get("Digits", "1")) if digit_pressed == 1: language = "english" else: language = "spanish" # Store (or update, if this redundant) the contact and message in the database contact, created = Contact.objects.get_or_create(phone_number=request.data['From'], defaults={ "uuid": uuid.uuid4(), "phone_number": request.data['From'], }) Message.objects.update_or_create(sid=request.data['CallSid'], defaults={ "timestamp": timezone.now(), "channel": enums.CHANNEL_VOICE, "sender": contact.uuid, "recipient": request.data['To'], "direction": enums.MESSAGE_INBOUND, "status": request.data['CallStatus'], "addons": messageutils.cleanup_json(request.data['AddOns']) if 'AddOns' in request.data else None, "raw": json.dumps(request.data), }) channel = twilioservice.get_or_create_chat_channel(contact.phone_number, str(contact.uuid)) attributes = { "from": str(contact.uuid), "language": language, "channel": channel.unique_name } response = VoiceResponse() enqueue = response.enqueue(None, workflow_sid=twilioauthservice.get_workflow().sid) enqueue.task(json.dumps(attributes)) response.append(enqueue) return HttpResponse(str(response))
# Download the Python helper library from twilio.com/docs/python/install from twilio.twiml.voice_response import VoiceResponse r = VoiceResponse() r.enqueue("Queue Demo") print(str(r))
from twilio.twiml.voice_response import Enqueue, VoiceResponse, Say response = VoiceResponse() response.enqueue('support', wait_url='wait.xml') response.say( 'Unfortunately, the support line has closed. Please call again tomorrow.') print(response)
from twilio.twiml.voice_response import VoiceResponse, Enqueue import os account_sid = os.environ.get("TWILIO_ACME_ACCOUNT_SID") auth_token = os.environ.get("TWILIO_ACME_AUTH_TOKEN") workspace_sid = os.environ.get("TWILIO_ACME_WORKSPACE_SID") workflow_sid = os.environ.get("TWILIO_ACME_SUPPORT_WORKFLOW_SID") resp = VoiceResponse() with resp.enqueue(None, workflowSid=workflow_sid) as e: e.task('{"selected_language" : "es", "Selected_department" : "test"}') print(resp) print("cheese")
def enqueue_call(): resp = VoiceResponse() resp.enqueue(None, workflowSid="WW0123456789abcdef0123456789abcdef") return str(resp)
from twilio.twiml.voice_response import Enqueue, VoiceResponse response = VoiceResponse() response.enqueue('support', wait_url='wait-music.xml') print(response)