亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

twilio 如何使用 PHP 和 JavaScript 從隊列中選擇呼叫

twilio 如何使用 PHP 和 JavaScript 從隊列中選擇呼叫

倚天杖 2022-07-08 10:20:35
我正在使用 twiml 創建一個呼叫排隊系統,一切正常,就像我可以接聽電話和排隊呼叫,但我無法從隊列中接聽電話,我寫了這段代碼,但它不工作當有來電時,這是我的 twiml:我接到第一個電話,其他后續電話排隊,但現在第一個電話結束后,我無法選擇排隊的電話。當我掛斷電話時,它會將第一個呼叫者排在隊列中。header("Content-type: text/xml");$name = $_POST['name'];$email = $_POST['email'];$message = '<?xml version="1.0" encoding="UTF-8"?><Response>    <Say>Please wait and one of our agents will be with you shortly.</Say>    <Dial>        <Client>joey</Client>        <Parameter name="name" value="'.$name.'" />        <Parameter name="email" value="'.$email.'" />    </Dial>    <Say>Our agents are still busy please hold.</Say>    <Enqueue waitUrl="waiting.php">Support</Enqueue></Response>';echo $message;因此,要從隊列中接聽電話,我發現了這個 Twilio PHP 代碼:use Twilio\TwiML\VoiceResponse;$support = $_REQUEST['To'];$response = new VoiceResponse();$response->say("You will now be connected to the first caller in the queue.");$dial = $response->dial('');$dial->queue($support, ['url' => 'about_to_connect.php']);echo $response;使用此 JavaSCript 代碼 queueButton.click(function() {        Twilio.Device.connect({            To: 'Support'        });    });在這里,我想按照這個答案Twilio 將代理連接到隊列中的呼叫但是當我單擊一個按鈕來接聽電話時,什么也沒有發生,而是我收到了這個 js 錯誤twilio.js:7100 Received an error from the gateway: {code: 31002, connection: Connection, message: "Connection Declined", twilioError: Errorcode: 31005description: "Connection error"explanation: "A connection error occurred during the call"總而言之,我只需要一個關于如何將代理連接到隊列的解決方案,例如查看隊列中有多少呼叫并能夠從隊列中選擇它們
查看完整描述

1 回答

?
鳳凰求蠱

TA貢獻1825條經驗 獲得超4個贊

我想到了。


所以要調用隊列,我需要第二個號碼,我可以用它來調用隊列,但我沒有第二個號碼,所以因為我有 twiml Gather 的 input.php 文件,我做了一個 if 語句檢查是否用戶呼叫是代理或只是客戶,如果是代理我撥打隊列


if($_POST['user_type'] == 'agent'){

  <Response>

    <Dial>

        <Queue url="about_to_connect.xml">my_queue_name</Queue>

    </Dial>

</Response>

}else{

  //My Gather here

}

為了能夠檢查用戶是代理還是客戶,當我調用隊列時,我傳遞了一個名為 user_type 的自定義變量:


let connection = Twilio.Device.connect({

  "user_type": "agent"

});

所以我可以打電話給我的隊列。那時我意識到 twiml 很棒,它的工作是控制調用。


我建議您購買第二個號碼以避免減慢您的通話速度。


查看完整回答
反對 回復 2022-07-08
  • 1 回答
  • 0 關注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號