ScreenCall进程不连接呼叫

时间:2016-05-12 13:49:41

标签: twilio

我有一个用例,有人调用我的Twilio号,然后Twilio尝试将调用者与代理连接起来。当代理#拿起时,我使用ScreenCall进程来确保它是一个人,他们必须按一个数字。问题是,一旦我进入ScreenCall流程,一切都在代理方面工作,但当他们按下一个数字时,呼叫者永远不会连接到他们。

我错过了什么?一旦我移除了屏幕呼叫,一旦座席应答,呼叫者和座席就会立即连接。

public ActionResult CallAgents(string From, string To, string CallSid)
    {
        var response = "<Response><Dial action = '" + Url.Action("EndCall", "Call") + "'>
 <Number action = '" + Url.Action("ScreenCall", "Call") + "'>1231231234</Number></Dial></Response>";

        return new TwiMLResult(response);
    }

 public ActionResult ScreenCall(string From, string To, string CallSid)
    {
        var response = new TwilioResponse();

        response.BeginGather(new { action = "AnswerCall", numDigits = 1 })
            .Say("Press any key to accept the call.")
            .EndGather();


        return new TwiMLResult(response);
    }

 public ActionResult AnswerCall(string From, string To, string CallSid)
    {
        var response = new TwilioResponse().Say("Thank you, you are now being connected.").Record();

        return new TwiMLResult(response);
    }

1 个答案:

答案 0 :(得分:0)

  

response.BeginGather(new {action =“AnswerCall”,numDigits = 1})

上面的

AnswerCall似乎只是一个字符串。 <Gather>的{​​{3}}需要绝对或相对URL作为值。当代理完成输入数字后,Twilio将对此URL发出GET或POST请求。发出此请求后,Twilio将使用您的回复中收到的TwiML继续当前通话。

您还可以查看本教程中的代码完整调用筛选示例:action attribute

当座席屏蔽呼叫时,那里的片段如下所示:

// POST: Agent/ScreenCall
[HttpPost]
public ActionResult ScreenCall(string from)
{
    var response = new TwilioResponse();
    var incomingCallMessage = "You have an incoming call from: " +
                              SpelledPhoneNumber(from);
    response.BeginGather(new {numDigits = 1, action = Url.Action("ConnectMessage")})
        .Say(incomingCallMessage)
        .Say("Press any key to accept")
        .EndGather();

    response.Say("Sorry. Did not get your response");
    response.Hangup();

    return TwiML(response);
}

// GET: Agent/ConnectMessage
public ActionResult ConnectMessage()
{
    return TwiML(new TwilioResponse()
        .Say("Connecting you now..."));
}