I'm currently implementing incoming call functionality using Twilio-PHP and TwiML. I'm asking for the callers permission to record the call, which works. However, as soon as I'm starting the recording, nothing after the <Record>
element is being executed. At this point, I somehow suppose this is expected behavior. Is there any way I can perform <Redirect>
s etc, while recording? The redirect works when the call is not being recorded. Here's the PHP file when the user comes back from the recording permission:
<?php
include_once('../../../includes/config.php');
require_once FULL_DIRECTORY.'vendor/autoload.php';
use Twilio\TwiML\VoiceResponse;
$language = 'de-DE';
$voiceSettings = ['voice' => 'woman', 'language' => $language];
$response = new VoiceResponse();
$callerResponse = trim(strtolower($_REQUEST["SpeechResult"]));
if(($callerResponse == "ja" || $callerResponse == "ya" || $callerResponse == "jo" || $callerResponse == "yes" || $callerResponse == "yea" || $callerResponse == "jaha") && $_REQUEST["Confidence"] > 0.8){
$response->say('Sie haben der Aufzeichnung zugestimmt.', $voiceSettings);
$response->record(['action' => '/webhook/twiml/push_recording.php', 'timeout' => 0]);
}else{
$response->say('Sie haben der Aufzeichnung nicht zugestimmt. Das Gespräch wird ohne Aufzeichnung fortgesetzt.', $voiceSettings);
}
$response->redirect('/webhook/twiml/ask_for_redirect.php', ['method' => 'POST']);
echo $response;
The very last line before the echo (the final redirect) only gets executed when the call is not being recorded.
Any solutions here?
Take a look at Twilio Call Recording Controls.