Exemple #1
0
def ivr_finished(request):
    """
    Kookoo invokes this view after a call is finished (whether answered or not)
    with status and some statistics.
    Point Kookoo's 'callback_url' parameter here.
    """
    # Retrieve all parameters
    status = request.POST.get("status", None)
    start_time = request.POST.get("start_time", None)
    caller_id = request.POST.get("caller_id", None)
    phone_no = request.POST.get("phone_no", None)
    sid = request.POST.get("sid", "")
    duration = request.POST.get("duration", None)
    ringing_time = request.POST.get("ringing_time", None)
    status_details = request.POST.get("status_details", None)

    gateway_session_id = "KOOKOO-" + sid

    with CriticalSection([gateway_session_id], timeout=300):
        call = Call.by_gateway_session_id(gateway_session_id)
        if call:
            log_metadata_received(call)
            try:
                duration = int(duration)
            except Exception:
                duration = None
            call.answered = (status == 'answered')
            call.duration = duration
            call.save()

    return HttpResponse('')
Exemple #2
0
def incoming(phone_number, gateway_session_id, ivr_event, backend=None, input_data=None,
        duration=None):
    """
    The main entry point for all incoming IVR requests.
    """
    call = Call.by_gateway_session_id(gateway_session_id)
    logged_subevent = None
    if call and call.messaging_subevent_id:
        logged_subevent = MessagingSubEvent.objects.get(
            pk=call.messaging_subevent_id)

    if call:
        add_metadata(call, duration)

    if call and call.form_unique_id is None:
        # If this request is for a call with no form,
        # then just short circuit everything and hang up
        return hang_up_response(gateway_session_id, backend=backend)

    if call and backend:
        return handle_known_call_session(call, backend, ivr_event,
            input_data=input_data, logged_subevent=logged_subevent)
    else:
        if not call:
            log_call(phone_number, gateway_session_id, backend=backend)
        return hang_up_response(gateway_session_id, backend=backend)
Exemple #3
0
def ivr_finished(request):
    """
    Kookoo invokes this view after a call is finished (whether answered or not)
    with status and some statistics.
    Point Kookoo's 'callback_url' parameter here.
    """
    # Retrieve all parameters
    status = request.POST.get("status", None)
    start_time = request.POST.get("start_time", None)
    caller_id = request.POST.get("caller_id", None)
    phone_no = request.POST.get("phone_no", None)
    sid = request.POST.get("sid", "")
    duration = request.POST.get("duration", None)
    ringing_time = request.POST.get("ringing_time", None)
    status_details = request.POST.get("status_details", None)

    gateway_session_id = "KOOKOO-" + sid

    with CriticalSection([gateway_session_id], timeout=300):
        call = Call.by_gateway_session_id(gateway_session_id)
        if call:
            log_metadata_received(call)
            try:
                duration = int(duration)
            except Exception:
                duration = None
            call.answered = status == "answered"
            call.duration = duration
            call.save()

    return HttpResponse("")
Exemple #4
0
def incoming(phone_number,
             gateway_session_id,
             ivr_event,
             backend=None,
             input_data=None,
             duration=None):
    """
    The main entry point for all incoming IVR requests.
    """
    call = Call.by_gateway_session_id(gateway_session_id)
    logged_subevent = None
    if call and call.messaging_subevent_id:
        logged_subevent = MessagingSubEvent.objects.get(
            pk=call.messaging_subevent_id)

    if call:
        add_metadata(call, duration)

    if call and call.form_unique_id is None:
        # If this request is for a call with no form,
        # then just short circuit everything and hang up
        return hang_up_response(gateway_session_id, backend=backend)

    if call and backend:
        return handle_known_call_session(call,
                                         backend,
                                         ivr_event,
                                         input_data=input_data,
                                         logged_subevent=logged_subevent)
    else:
        if not call:
            log_call(phone_number, gateway_session_id, backend=backend)
        return hang_up_response(gateway_session_id, backend=backend)