1

I have been searching for a work around, but I cannot find anything that guarantees action after recording a voicemail. I have to use my server to check call status to end the call and prevent if from going to voicemail after a completed call when using multi-dial. After we record the voicemail I need to SMS a link to the recording for each employee who missed the call. The only way it works is if the caller presses a button before hanging up. I have been trying to use the RecordingStatusCallback as a work around, but I can't figure out how to ensure that the SMS sends if a recording is received.

    <?php
    header('content-type: text/xml');
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    $dial_call_status = $_REQUEST['DialCallStatus'];
    if($dial_call_status == "completed" || $dial_call_status == "answered"){
    ?>
      <Response>
        <Hangup/>
     </Response>
    <?php
    }else{
    ?>
      <Response>
        <Record
            action="https://handler.twilio.com/twiml/responsefromserver"
            transcribe="true"
            maxLenth="20"
            RecordingStatusCallbackEvent="Completed"
            RecordingStatusCallback="https://handler.twilio.com/twiml/XXXX"
            transcribeCallback="http://twimlets.com/voicemail?Email=jk@XXXX.com"/>
       </Response>
     <?php
     }
     ?>

Response from Server:

   <?xml version="1.0" encoding="UTF-8"?>
   <Response>
     <Say> Thankyou for leaving a message </Say>
   <Sms to="1XXXXXXX"> John
       You missed a call from {{From}} voice Recording: {{RecordingUrl}}.
    </Sms>
    <Sms to="1XXXXXX"> Joe
        You missed a call from {{From}} voice Recording: {{TranscriptionText}}.
    </Sms>  
    </Response>

2 Answers2

0

The recordingStatusCallback can trigger a Twilio Function that can send the SMS’ to the respective parties.

Send Multiple SMS

Alan
  • 10,465
  • 2
  • 8
  • 9
0

First up, the <Sms> TwiML verb is very deprecated. I do not recommend you use it.

Instead, I would recommend you trigger the messages that you want to send by using the REST API's messaging resource when you receive the recording status callback, rather than trying to do as part of the call in TwiML. The recording status callback is an asynchronous webhook that will not affect the call if you respond with TwiML. Any actions you want to take in a recording status callback webhook should be with the REST API.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • It is unfortunate that the Sms verb has been deprecated and not replaced. I am trying to keep as much code as possible in the Twiml bin for simplicity and security. I suspected the Recording status callback was only going to be compatible with the API. I was hoping it could at least trigger something with some simplicity. Do you have any sample code that could be loaded as a function to grab the trigger and then trigger a Twiml bin? Might there possibly be a work around to enable the message verb to send sms in response to voice calls when we hit a function? – Rio Electronics Jul 29 '22 at 22:20
  • The Sms verb has been deprecated because it is better to use the REST API and doesn't rely on the call to be continuing. In particular, you could never have used the Sms verb in response to the recording status callback because Twilio doesn't execute TwiML responses to asynchronous webhooks like the recording status callback. I'm not sure what else you're asking here, if you want to send a message in response to the recording status callback, you will need to use the REST API not a TwIML Bin. – philnash Jul 30 '22 at 11:28