[Fixed]-Twilio record outgoing browser call and store the record id in an object Django

1👍

Twilio developer evangelist here.

You can record the call by using the record attribute on the <Dial> verb. Set it to "record-from-answer" to record the call.

You will also want to set the recordingStatusCallback attribute to a URL in your application. Twilio will make an HTTP request with the details of the call and recording when the recording is ready, passing these parameters.

@csrf_exempt
def call(request):
    """Returns TwiML instructions to Twilio's POST requests"""
    response = twiml.Response()

    with response.dial(callerId=settings.TWILIO['SOURCE_NUMBER'], record='record-from-answer', recordingStatusCallback='/recording') as r:
        r.number(request.POST['phone_number'])

    return HttpResponse(str(response))

Then you can use the parameters passed to the recordingStatusCallback to save the details in your database.

Let me know if that helps.

Leave a comment