I have a simple call structure folder with PHP and XML on my server. To handle my incoming calls for my business.
I can’t seem to get it to forward to voicemail without errors.
Here is how the call gets triggered.
Customer Calls -> Routes to Webhook -> Handle-Incoming-Call.XML
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Redirect>handle-extension.php</Redirect>
</Response>
Then Handle-Extension.PHP looks like this
<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<Response>';
# @start snippet
echo '<Say>Thank you for calling, My Business</Say>';
echo '<Dial record="true" timeout="15" action="voicemail.php">';
echo '<Number url="screen-caller.xml">+10000000000</Number>';
echo '</Dial>';
# @end snippet
echo '</Response>';
?>
Then Screen-Caller.XML looks like this (This is what me as a business will hear when I pick up)
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="handle-screen-input.php" numDigits="1">
<Say>Call for Your Business</Say>
<Say>To accept the call, press 1.</Say>
<Say>To reject the call, press 2.</Say>
</Gather>
</Response>
When I press 1 I get the call, but when I press 2 I want it to go to voicemial.
Here is the Handle-Screen-Input.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, say hello.</Say>';
}
else {
echo '<Hangup />';
}
echo '</Response>';
?>
I did a bypass for now so I created another Webhook to go to a TwimLets Forwarding Voicemail to Email when it fails.
Here is the fail message I get from LOGS
An attempt to retrieve content from https://website.com/callsystem/voicemail.php returned the HTTP status code 500. Falling back to http://twimlets.com/voicemail?Email=email%40email.com&Message=Please%20leave%20a%20message%20after%20the%20beep.&Transcribe=true&
So when it gets to the error it goes to my fallback WebHook, I still get the voicemail but I get tons of error logs at the end of the day.
I am trying to figure out what I am missing to get the voicemail.php to work.
Here is the voicemail.php code I found in one of the posts here in Stack.
header("content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
$email = $_REQUEST['email'];
?>
<Response>
<?php if ($_REQUEST['DialCallStatus'] == 'completed') { ?>
<Hangup/>
<?php } else { ?>
<Say>Sorry Our Business is not available at this time, Please leave a message at the tone. Press the star key when finished.</Say>
<Record transcribe="true" action="goodbye.php" transcribeCallback="voicemail-send.php?email=<?php echo $email; ?>" maxLength="120" finishOnKey="*" />
<Say>I did not receive a recording.</Say>
<Redirect>voicemail.php</Redirect>
<?php } ?>
</Response>
Do I need to add a file name “voicemail-send.php” if so what is that structure look like?
Any help would be greatly appreciated. Thank you