感謝您花時間閱讀我的文章。我試圖設置一個IVR在我的一個客戶帳戶上測試,以處理工作時間以外的來電等。我是Twilio和PHP的新手。Twilio IVR用戶輸入處理問題
下面是XML代碼,它似乎正常運行:所以
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="handle-user-input.php" numDigits="1">
<Say voice="woman">Welcome to COMPANY.</Say>
<Say voice="woman">In order to further assist you. Please listen to the following:</Say>
<Say voice="woman">For an option, please press 1.</Say>
<Say voice="woman">For a different option, please press 2.</Say>
<Say voice="woman">To speak with another person, please press 3.</Say>
<Say voice="woman">For all other inquiries, please press 4.</Say>
</Gather>
<!-- If they didnt put an input say this then retry -->
<Say voice="woman">Sorry, I didn't get your response.</Say>
<Redirect>http://www.exampleforstackoverflow.com/handle-incoming-call.xml</Redirect>
</Response>
,如果你要調用的是指向這個xml文件的twilio號碼,語音選項玩,似乎工作正常。如果你要按輸入 - 你會得到一個應用程序錯誤。的PHP文件是手柄用戶input.php如下:
<?php
$dayofweek=date('D');
$hour=date('H');
if(($dayofweek!='Sat')&&($dayofweek!='Sun')){
if(($hour>17)&&($hour<23)){
//ok time to call
$ok='1';
}
}
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 voice="woman">Connecting you to, sales.</Say>';
if($ok!='1'){
echo '<Redirect>http://twimlets.com/[email protected]&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else if ($user_pushed == 2) {
echo '<Say voice="woman">Connecting you to some person.</Say>';
if($ok!='1') {
echo '<Redirect>http://twimlets.com/[email protected]&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else if ($user_pushed == 3) {
echo '<Say voice="woman">Connecting you to a person.</Say>';
if($ok!='1') {
echo '<Redirect>http://twimlets.com/[email protected]&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else if ($user_pushed == 4) {
echo '<Say voice="woman">Connecting you to, operator.</Say>';
if($ok!='1') {
echo '<Redirect>http://twimlets.com/[email protected]&Message=http://www.example.com/ftZLg.mp3</Redirect>';
} else {
echo '<Dial>+12345678901</Dial>';
}
} else {
echo "<Say voice="woman">Sorry, You dialed an invalid number.</Say>";
echo '<Redirect>http://www.exampleforstackoverflow.com/handle-incoming-call.xml</Redirect>';
}
echo '</Response>';
?>
我不知道是否有在我的PHP文件中的錯誤,也許有。但是,我注意到,在我的Twilio錯誤日誌中,我發現請求超時訪問文件。換句話說,當Twilio嘗試訪問它時,http://example.com/handle-user-input.php給出了錯誤500。
無論如何,感謝您花時間閱讀我的文章。如果有人對我的錯誤有一些洞察力,那將是非常棒的!