Twilio Screen Caller with Voicemail -
my goal have ability screen incoming calls, , send them voicemail. below code screening correctly, if answer call , and hangup call dropped instead of directing voicemail. how can accomplish this?
<say>please wait while connect aaron. calls may recorded quality assurance purposes.</say> <dial action="voicemail.php?email=aaron" timeout="15"> <number url="screen-caller.xml">+11231231234</number> </dial>
screen-caller.xml:
<response> <gather action="handle-screen-input.php" numdigits="1"> <say>to accept, press 1.</say> </gather> <!-- if customer doesn't input anything, prompt , try again. --> <say>sorry, didn't response.</say> <redirect>screen-caller.xml</redirect> </response>
handle-screen-input.php:
echo '<?xml version="1.0" encoding="utf-8"?>'; echo '<response>'; $user_pushed = (int) $_request['digits']; if ($user_pushed == 1) { echo '<say>connecting. calls recorded.</say>'; } else { echo '<hangup />'; } echo '</response>';
voicemail.php:
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>please leave message @ beep. press 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 recording.</say> <redirect>voicemail.php</redirect> <?php } ?> </response>
[[ edit ]]
ahhh! know is! below answer (which i've kept posterity) straight wrong.
when person being dialled , getting whisper hangs up, action
on <dial>
verb called. documentation, the dialcallstatus
values can be: completed, busy, no-answer, failed or canceled. when person picks phone status cannot busy, no-answer, failed or canceled. when hang before whisper over, call status completed.
so, when action gets called, dialcallstatus
completed , voicemail.php hang up.
you sent dialcallduration
, check how long call went on , work out whether call connected or person hung up.
hope helps now!
[[ original answer ]]
twilio developer evangelist here.
if hang during whisper part of call original caller continue make way through twiml given. in case, give them <dial>
verb, once hang on end, caller completes <dial>
action, gets end of twiml , hangs up.
try adding <redirect>/voicemail.php?email=aaron</redirect>
after <dial>
in first twiml.
let me know if helps.