2016-01-20 114 views
1

我想連接該流程中的兩個電話號碼:Twilio(TwiML):撥打另一個電話

Person_1正在應答呼叫。播放語音消息並詢問他是否願意參加電話會議。只有當PERSON_1接受電話會議將啓動:

這就是我要做的:

Intro.chtml:

<Response> 
    <Gather numDigits="1" action="StartConferenceCall.chtml" method="GET"> 
     <Say>Press 1 to start the conference call</Say> 
    </Gather> 
</Response> 

StartConferenceCall.chtml:

@{ 
    var digits = Request["Digits"]; 
    if(digits == "1") 
    { 
     <Response> 
     <Dial> // I would like to dial the second person 

      <Conference beep="false" record="record-from-start" 
       Room 1234 
      </Conference> 
     </Dial> 
     </Response> 
    } 
    else 
    { 
     <Hangup/> 
    } 

} 

是否可以將第二個數字添加到<Dial> t ag?

回答

1

Twilio開發者傳道士在這裏。

因爲你已經改變了原來的問題,我刪除了我以前的答案,併爲你提供了另一個例子。

因爲您想自己開始呼叫並讓用戶按1以防萬一他們想接受該問題,您將要使用REST API。具體來說,你想initiate a new call,然後會提示用戶按下按鈕。下面的代碼是C#。

public void CallUser(){ 
    var client = new TwilioRestClient(AccountSid,AuthToken); 
    client.InitiateOutboundCall("from", "to", "/Call"); 
    client.InitiateOutboundCall("from", "to", "/Conference"); 
} 

在上面的代碼中,我發起了兩個調用。一個給客戶,一個給應該在線的其他人。如果你願意,你可以改變邏輯,但爲了簡化事情,我同時啓動兩個呼叫。

然後第一個呼叫將使用戶放到菜單上,他們可以按1來加入呼叫。然後

public IActionResult Call() 
{ 
    var twiml = new TwilioResponse(); 
    return TwiML(twiml.BeginGather(new { action = "/Conference", numDigits = "1" }).Say("Press 1 to start the conference call").EndGather()); 
} 

兩個呼叫重定向到/conference,在那裏創建或加入會議室。你可以有邏輯來檢查用戶是否在這裏撥打1

public IActionResult Conference() 
{ 
    var twiml = new TwilioResponse(); 
    return TwiML(twiml.DialConference("Room 1234")); 
} 

希望這有助於你

+0

增加了一個新的鏈接,我的回答與文檔發起新的呼叫。希望這有助於 –

+0

如何在這裏添加命令「從開始記錄」?謝謝。 – Eyal

+0

沒關係,我在這裏找到它:https://sites.google.com/site/dezpatterns/cloud/twilio/twilio-dial-conference-with-attributes – Eyal