def menu(request: request.HttpRequest): try: _ = request.META['HTTP_X_TWILIO_SIGNATURE'] digit = request.POST.get('Digits') from_number = request.POST.get("From").strip("+") call_sid = request.POST.get("CallSid") channel_layer = channels.layers.get_channel_layer() resp = VoiceResponse() #record if digit == '1': resp.say("Please leave a message. Press the pound or hash key to end the recording.") #without an action or recording_status_callback attribute then you will have an endless loop of calling into the view resp.record(play_beep=True, max_length=30, finish_on_key="#", recording_status_callback="/api/record/", action="/api/hangup/") async_to_sync(channel_layer.group_send)(f"chat_{from_number}", {"type": "chat_message", "message": 'Incoming recording...'}) #stream elif digit == '2': caller: Caller = Caller.objects.get(number=from_number) Call(sid=call_sid, length_of_call=0, caller_id=caller.id, call_type="L").save() redisController.set(key=call_sid,value=from_number) async_to_sync(channel_layer.group_send)(f"chat_{from_number}", {"type": "chat_message", "stream": True, "message": 'Incoming stream...'}) resp.say("Please begin speaking...") connect = Connect() connect.stream(url=ws_url) resp.append(connect) else: resp.say("Incorrect entry. Please try again.") resp.redirect('/api/voice/') return HttpResponse(str(resp)) except KeyError: return
def connect_call(): """ Connects the call to autopilot """ app.logger.info("Connecting call to autopilot task.") response = VoiceResponse() connect = Connect() connect.autopilot(ASSISTANT_SID, TargetTask="conduct_interview") response.append(connect) response = make_response(str(response)) response.headers['Content-type'] = 'text/html; charset=utf-8' return response
from twilio.twiml.voice_response import Connect, VoiceResponse, Stream response = VoiceResponse() connect = Connect() connect.stream(url='wss://mystream.ngrok.io/audiostream') response.append(connect) print(response)
from twilio.twiml.voice_response import Connect, VoiceResponse, Room response = VoiceResponse() connect = Connect() connect.room('meeting', status_callback='https://myactionurl.com/') response.append(connect) print(response)
from twilio.twiml.voice_response import Connect, VoiceResponse, VirtualAgent response = VoiceResponse() connect = Connect(action='https://myactionurl.com/twiml') connect.virtual_agent(connector_name='project', status_callback='https://mycallbackurl.com') response.append(connect) print(response)
from twilio.twiml.voice_response import Connect, VoiceResponse, Room response = VoiceResponse() connect = Connect(action='https://myactionurl.com/', timeout='5') connect.room('meeting', status_callback='https://myactionurl.com/', media_region='ie1') response.append(connect) print(response)
from twilio.twiml.voice_response import Connect, VoiceResponse, VirtualAgent response = VoiceResponse() connect = Connect() connect.virtual_agent(connector_name='project', language='fr') response.append(connect) print(response)
from twilio.twiml.voice_response import Connect, VoiceResponse, VirtualAgent response = VoiceResponse() connect = Connect() connect.virtual_agent(connector_name='project', sentiment_analysis=True) response.append(connect) print(response)
from twilio.twiml.voice_response import Connect, VoiceResponse, Room response = VoiceResponse() connect = Connect() connect.room('DailyStandup') response.append(connect) print(response)
from twilio.twiml.voice_response import Connect, VoiceResponse, Room response = VoiceResponse() connect = Connect() connect.autopilot('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') response.append(connect) print(response)