2016-05-12 34 views
0

我有一個用戶呼叫我的Twilio號碼,然後Twilio嘗試連接呼叫者與代理的用例。當代理人#拿起我使用ScreenCall過程,以確保它是一個人,他們必須按數字。問題是,只要進入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); 
    } 

回答

0

response.BeginGather(新{行動= 「AnswerCall」 numDigits = 1})

在上述AnswerCall似乎僅僅是一個字符串。 <Gather>action attribute需要絕對或相對URL作爲值。當代理完成輸入數字時,Twilio將向此URL發出GET或POST請求。提出此請求後,Twilio將使用您在回覆中收到的TwiML繼續當前的呼叫。

您還可以檢查出代碼完整的呼叫篩選本教程例如:https://www.twilio.com/docs/tutorials/walkthrough/ivr-screening/csharp/mvc#4

的片段有當代理篩選通話看起來是這樣的:

// 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...")); 
} 
+0

我試着開關了這一點,但沒有更改。 – ToddB

+0

發現問題。一旦screenCall處理完畢並且有人接受了該呼叫,它就會發出「記錄」命令。通過支持樣本做的事情來證明我不是。 – ToddB