Twilio IVR用户输入处理问题
感谢您花时间阅读我的文章。我试图设置一个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。
无论如何,感谢您花时间阅读我的文章。如果有人对我的错误有一些洞察力,那将是非常棒的!
你有一个回声双引号: 回声“对不起,你拨了一个无效的号码。”;
更新,要
echo '<Say voice="woman">Sorry, You dialed an invalid number.</Say>';
而且我得到这个从PHP返回(没有张贴数字等):
<?xml version="1.0" encoding="UTF-8"?> <Response> <Say voice="woman">Sorry, You dialed an invalid number.</Say> <Redirect>http://www.exampleforstackoverflow.com/handle-incoming-call.xml</Redirect> </Response>
如果你是新来的PHP,看看一个用于语法检查的IDE,或者一种用于一次性检查的代码验证,如http://phpcodechecker.com/。 How do I get PHP errors to display?
:如果你有机会,你也可以通过下面这样的打开错误报告你的PHP服务器上