I'm building an application where I want the call recordings URL and duration of the call captured upon completion of the call.
My recordingStatusCallback
handler requests keep returning with a status 400 and I don't know why it is doing that or how I could debug this further.
Here is my Recordings
handler:
[HttpPost]
public void Recordings([FromForm] VoiceRequest request)
{
// TODO: Get the recording URL and log it to the database for the call
Console.WriteLine($"CallSID: {request.CallSid}");
Console.WriteLine($"RecordingUrl: {request.RecordingUrl}");
Console.WriteLine($"RecordingDuration: {request.RecordingDuration}");
// Not sure what happens here... testing it out if transcriptions are available...
Console.WriteLine($"TranscriptionUrl: {request.TranscriptionUrl}");
}
For reference, I have a similar handler for statusCallbackEvent
- see this snippet:
[HttpPost]
public void Events([FromForm] VoiceRequest request)
{
Console.WriteLine($"CallSID: {request.CallSid}");
Console.WriteLine($"CallStatus: {request.CallStatus}");
Console.WriteLine($"DialCallDuration: {request.DialCallDuration}");
}
And this Events
function is being called correctly without issues.
I'd appreciate your help!
I'm building an application where I want the call recordings URL and duration of the call captured upon completion of the call.
My recordingStatusCallback
handler requests keep returning with a status 400 and I don't know why it is doing that or how I could debug this further.
Here is my Recordings
handler:
[HttpPost]
public void Recordings([FromForm] VoiceRequest request)
{
// TODO: Get the recording URL and log it to the database for the call
Console.WriteLine($"CallSID: {request.CallSid}");
Console.WriteLine($"RecordingUrl: {request.RecordingUrl}");
Console.WriteLine($"RecordingDuration: {request.RecordingDuration}");
// Not sure what happens here... testing it out if transcriptions are available...
Console.WriteLine($"TranscriptionUrl: {request.TranscriptionUrl}");
}
For reference, I have a similar handler for statusCallbackEvent
- see this snippet:
[HttpPost]
public void Events([FromForm] VoiceRequest request)
{
Console.WriteLine($"CallSID: {request.CallSid}");
Console.WriteLine($"CallStatus: {request.CallStatus}");
Console.WriteLine($"DialCallDuration: {request.DialCallDuration}");
}
And this Events
function is being called correctly without issues.
I'd appreciate your help!
Share Improve this question edited Mar 12 at 21:15 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Mar 12 at 21:01 punsandgunspunsandguns 693 bronze badges1 Answer
Reset to default 0After lots of trial and error, I stumbled upon the solution to my problem. For whatever reason, the statusCallback
and the recordingStatusCallback
are not treated the same. The handler that eventually does work for me is as below
public async System.Threading.Tasks.Task RecordingsAsync()
{
// TODO: Get the recording URL and log it to the database for the call
var form = await Request.ReadFormAsync();
Console.WriteLine($"CallSid: {form["CallSid"]}");
Console.WriteLine($"RecordingUrl: {form["RecordingUrl"]}");
Console.WriteLine($"RecordingDuration: {form["RecordingDuration"]}");
}
I'm only accessing 3 values here but there are more parameters you can access - read about them here https://www.twilio/docs/voice/api/call-resource#parameters-sent-to-your-recordingstatuscallback-url
I would still like a Twilio expert to comment on whether my solution is the right way to do this or if there is a better-prescribed approach that should be considered.