通过邮件向twilio语音通话中的收件人发送录音

时间:2019-09-17 10:41:01

标签: c# .net twilio

我想在通话完成后通过twilio语音呼叫通过邮件将记录发送给收件人。有人可以建议如何实现吗?

1 个答案:

答案 0 :(得分:0)

我有解决方案,我们可以通过在接收或拨打电话时设置RecordingStatusCallback,然后处理RecordingStatusCallback,并根据要求将录音发送给接收者来实现此目的:

 public CallResource MakeOutboundPhoneCallsAsync(OutgoingCallRequest request, string accountSid, string authToken, Guid userId)
    {
        try
        {
            TwilioClient.Init(accountSid, authToken);
            List<string> statusCallbackEvent = new List<string> { "answered", "completed" };
            CallResource response =
                CallResource.Create(
                            url: new Uri("http://demo.twilio.com/docs/voice.xml"),
                            to: new PhoneNumber(request.ToPhoneNumber),
                            from: new PhoneNumber(request.FromPhoneNumber),
                            method: Twilio.Http.HttpMethod.Get,
                            record: request.Record,
                            recordingStatusCallback: baseUrl + "/api/Twilio/OutboundCalls/RecordingStatusCallback",
                            recordingStatusCallbackMethod: Twilio.Http.HttpMethod.Post
                        );

            return response;

        }
        catch (Exception e)
        {
            throw e;
        }
    }

,然后像在控制器中一样处理回叫:

 [HttpPost("RecordingStatusCallback")]
    public IActionResult RecordingStatusCallback()
    {        
            //Get callback values here and write code To send email
    }