I'm handling incoming call using TaskRouter with conference instruction like so
@csrf_exempt
def TaskEnqueue(request):
""" Put call into queue """
response = VoiceResponse()
digits = request.POST['Digits']
selected_service = 'Support' if digits == '1' else 'Sales'
task = {'selected_service': selected_service}
enqueue = response.enqueue(None, workflowSid=TWILIO_WORKFLOW_SID)
enqueue.task(json.dumps(task))
return HttpResponse(
str(response), content_type='application/xml; charset=utf-8'
)
@csrf_exempt
def TaskAssignmentView(request):
""" Task assignment """
worker_attributes = json.loads(request.POST['WorkerAttributes'])
assigned_worder_uri = worker_attributes['contact_uri']
response = {'instruction': 'conference',
'from': TWILIO_NUMBER,
'to': assigned_worder_uri,
'end_conference_on_exit': True,
'post_work_activity_sid': TWILIO_ACTIVITY_BREAK}
return JsonResponse(response)
I'd like to end conference after either agent or caller hangs up.
Even with "end_conference_on_exit" property the conference is ended only when agent hangs up but not when caller hangs up.
Am I missing anything?
It's enough to add "end_conference_on_customer_exit" to the conference instruction.
response = {'instruction': 'conference',
'from': TWILIO_NUMBER,
'to': assigned_worder_uri,
'end_conference_on_exit': True,
'post_work_activity_sid': TWILIO_ACTIVITY_BREAK,
'end_conference_no_customer_exit': True
}