2016-09-26 62 views
2

我需要幫助。我有一個代理和客戶的情況。如果代理進行外撥呼叫並由客戶端回答,我的系統上會有一個按鈕,用於將代理和客戶端重定向到會議。下面的代碼是我的功能,撥打代理輸入的號碼。Twilio呼出電話到會議

function dialCall(num) 
{ 
    params = {"phoneNumber": num, "record":"record-from-answer", "callStatus":"call", "callerId": callerId, "caller":agent_id}; 
    conn = Twilio.Device.connect(params); 
    initializeStatus('Busy'); 
    isDialCall = true; 
    return conn; 
} 

所以,問題是是否有可能把主叫方和被叫方會議在同一時間?

回答

2

這是完全可能的。 在上面提到的代碼中,Twilio.Device.connect(params)會調用與您帳戶中的TwiML App關聯的語音URL。

這個聲音URL能做做在同一個會議上撥打這兩個主叫方和Calle的功能,下面兩件事

  1. 通過回饋的TwiML響應<Dial><Conference>
  2. 啓動撥入會議呼叫者REST API呼叫到目的地,並將URL設置爲將其撥入同一會議的端點。

樣品代碼(的NodeJS)如下

app.get("/handleOutgoingAsConference",function(i_Req,o_Res) 
{ 
    var ivrTwilRes = new twilio.TwimlResponse(); 
    var agentNum=i_Req.query.phoneNumber; 
    /*read other params here */ 
    ivrTwilRes.dial(
    function(node) { 
     node.conference('Conference_Caller_Callee', { beep:'false' , endConferenceOnExit:'true'}) 
    } 
); 
    var restClient = new twilio.RestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN); 
    restClient.calls.create(
    { 
     url: "/justDialIntoConference", 
     to: agentNum, 
     from: "+yourCallerId", 
     method: "GET", 
    }, 
    function(err, call) 
    { 
     if(err) 
     { 
      console.log(err.message); 
     } 
    } 
); 
    o_Res.set('Content-Type','text/xml'); 
    o_Res.send(ivrTwilRes.toString()); 
}); 

app.get("/justDialIntoConference",function(i_Req,o_Res) 
{ 
    var ivrTwilRes = new twilio.TwimlResponse(); 
    ivrTwilRes.dial(
    function(node) { 
     node.conference('Conference_Caller_Callee', { beep:'false' , endConferenceOnExit:'true'}) 
    } 
); 
    o_Res.set('Content-Type','text/xml'); 
    o_Res.send(ivrTwilRes.toString()); 
}); 

你可以結合上述兩種功能列出的,我使其分離爲簡單起見。

希望它有幫助