C# 等待后录制语音邮件

C# 等待后录制语音邮件,c#,.net,twilio,C#,.net,Twilio,我正在尝试实现语音邮件,但由于某些原因,它在10秒后立即挂断,并且不会播放该消息。到目前为止我有 [HttpPost] public ActionResult Connect(string phoneNumber, string called) { var response = new VoiceResponse(); var dial = new Dial(callerId: _credentials.PhoneNumber, timeout: 10); if (ph

我正在尝试实现语音邮件,但由于某些原因,它在10秒后立即挂断,并且不会播放该消息。到目前为止我有

[HttpPost]
public ActionResult Connect(string phoneNumber, string called)
{
    var response = new VoiceResponse();

    var dial = new Dial(callerId: _credentials.PhoneNumber, timeout: 10);
    if (phoneNumber != null)
    {
        dial.Number(phoneNumber);
    }
    else
    {
        int agentId = 1;
        dial.Client("support_agent", statusCallback: Url.Action("Status", "Call", new { Area = "PhoneSystem", agentId }, Request.Url.Scheme));
    }
    response.Dial(dial);

    return TwiML(response);
}

[HttpPost]
public ActionResult Status(string agentId, string dialCallStatus, string callStatus)
{
    // Need to pass the agent so we know who is called
    if (dialCallStatus == "completed")
    {
        var emptyResponse = new XDocument(new XElement("Root", ""));
        return new TwiMLResult(emptyResponse);
    }

    var response = new VoiceResponse();

    response.Say(
        body: "We can't answer your call right now, please leave a message" 
    );

    // Use <Record> to record the caller's message
    response.Record();

    // End the call with <Hangup>
    response.Hangup();

    return TwiML(response);
}

这里是Twilio开发者福音传道者

用于获取有关调用状态的异步回调。它不允许您继续通话

相反,您应该使用来设置拨号呼叫完成后应执行的操作


让我知道这是否有帮助。

我添加了action属性,但该属性不会被调用,也不会挂断。能否将更改的代码添加到问题中?您的操作属性指向哪个URL?运行的操作是什么?谢谢
[HttpPost]
public ActionResult Connect(string phoneNumber, string called)
{
    var response = new VoiceResponse();

    int agentId = 1;
    var action = Url.Action("Status", "Call", new { Area = "PhoneSystem", 
      agentId }, Request.Url.Scheme);

    var dial = new Dial(callerId: _credentials.PhoneNumber, timeout: 10, action: new Uri(action));

    if (phoneNumber != null)
    {
        dial.Number(phoneNumber);
    }
    else
    {           
        dial.Client("support_agent");
    }
    response.Dial(dial);

    return TwiML(response);
}