Reputation: 17
After a successful call completion, I want to store the call status, duration, and recording URL of the call in my database, i have created an API for the status call back URL and put it into to Twilml App. in the status call back url section with post method.
public async Task<IActionResult> statuscallback()
{
Response response = new Response();
Exception exception = new Exception();
NotImplementedException _defaultEx = new NotImplementedException("No exception has been passed to the log method");
StatusCallResponse statusCallResponse = new StatusCallResponse();
statusCallResponse.CallDuration = HttpContext.Request.Form["CallDuration"].FirstOrDefault();
statusCallResponse.CallStatus = HttpContext.Request.Form["CallStatus"].FirstOrDefault();
statusCallResponse.SipResponseCode = HttpContext.Request.Form["SipResponseCode"].FirstOrDefault();
statusCallResponse.RecordingDuration = HttpContext.Request.Form["RecordingDuration"].FirstOrDefault();
statusCallResponse.RecordingSid = HttpContext.Request.Form["RecordingSid"].FirstOrDefault();
statusCallResponse.RecordingUrl = HttpContext.Request.Form["RecordingUrl"].FirstOrDefault();
string patientId = HttpContext.Request.Query["patientId"].ToString();
CallRecordingAdd add = new CallRecordingAdd();
add.RecordingSid= statusCallResponse.RecordingSid;
add.RecordingUrl = statusCallResponse.RecordingUrl;
add.Timestamp = statusCallResponse.RecordingDuration;
add.PatientId =patientId;
response = await _twilioCallService.CallRecordingAddAsync(add).ConfigureAwait(false);
response.Message = "call connected";
return Ok(response);
}
Upvotes: 0
Views: 28