2015-11-16 95 views
-2
<Response> 
    <Dial> 
     <Number url="other-script"> 
      4151234567 
     </Number> 
    </Dial> 
</Response> 

我嘗試上面的代碼,但它不適用於耳語消息。我想問一下在'other-script'頁面上寫什麼?twilio中的悄悄話消息php

回答

1

請詳細說明問題。 請參閱此頁https://www.twilio.com/docs/tutorials/ivrs-extensions 下載ivr.zip。

請參考本代碼 - IVR日誌和報告文件

header('Content-type: text/xml'); 
echo '<?xml version="1.0" encoding="UTF-8"?>'; 

echo '<Response>'; 

$user_pushed = (int) $_REQUEST['Digits']; 

if ($user_pushed == 0) 
{ 
    echo '<Say>Taking you back to the main menu</Say>'; 
    echo '<Redirect>handle-incoming-call.xml</Redirect>'; 
} 
else if ($user_pushed == 1) 
{ 
    echo '<Say>Connecting you to agent 1. All calls are recorded.</Say>'; 
    echo '<Dial record="true">'; 
    echo '<Number url="screen-caller.xml">+1NNNNNNNNNN</Number>'; 
    echo '</Dial>'; 
} 
else if ($user_pushed == 2) 
{ 
    echo '<Say>Connecting you to agent 2. All calls are recorded.</Say>'; 
    echo '<Dial record="true">'; 
    echo '<Number url="screen-caller.xml">+1NNNNNNNNNN</Number>'; 
    echo '</Dial>'; 
} 
else { 
    echo "<Say>Sorry, that extension is unknown.</Say>"; 
    echo '<Redirect method="GET">handle-user-input.php?Digits=2</Redirect>'; 
} 

echo '</Response>'; 
0

Twilio開發者傳道這裏。

"other-script"在這種情況下,需要指向一個URL,它會在接到呼叫的人之前將您要播放的TwiML作爲「Whisper」發送給接聽電話的人。

所以,如果你只是想的人被稱爲連接到主叫方,你需要"/other-script"爲指向讀取文件之前收到語音消息:

<Response> 
    <Say>You are being connected to a caller.</Say> 
</Response> 

這隻會讀出消息,然後連接兩個呼叫。

如果你想用「耳語」給呼叫者一個選項,拒絕呼叫,則需要"/other-script"指向一個腳本,說是這樣的:

<Response> 
    <Gather action="/handle-input" numDigits="1"> 
    <Say>You are receiving a call. Dial one to accept and any other digit to decline</Say> 
    </Gather> 
    <!-- If customer doesn't input anything, prompt and try again. --> 
    <Say>Sorry, I didn't get your response.</Say> 
    <Redirect>/other-script</Redirect> 
</Response> 

在這種情況下,你將需要在"/handle-input"也提供一些TwiML。這需要根據數字輸入進行操作,因此需要使用腳本。我看你標記的問題PHP,所以這裏是它可能看起來像在PHP中:

<?php 
    header('Content-type: text/xml'); 
    echo '<?xml version="1.0" encoding="UTF-8"?>'; 
    echo '<Response>'; 

    $user_pushed = (int) $_REQUEST['Digits']; 

    if ($user_pushed == 1) 
    { 
    echo '<Say>Connecting you to the caller.</Say>'; 
    } 
    else { 
    echo '<Hangup />'; 
    } 

    echo '</Response>'; 
?> 

這將連接電話,如果接到電話的人在系統提示撥1或對方掛斷電話撥打任何其他數字。

Twilio文檔中提供了關於call whispers and recording calls的更深入的教程,您可能也會發現它們也有用。