/** * Responds with a welcome message with instructions * * @return \Illuminate\Http\Response */ public function showWelcome() { $response = new Twiml(); $gather = $response->gather(['numDigits' => 1, 'action' => route('main-menu', [], false), 'method' => 'GET']); $gather->play('http://howtodocs.s3.amazonaws.com/et-phone.mp3', ['loop' => 3]); return $response; }
/** * Responds with instructions to choose a planet * @return Services_Twilio_Twiml */ private function _getPlanetsMenu() { $response = new Twiml(); $gather = $response->gather(['numDigits' => '1', 'action' => route('extension-connection', [], false), 'method' => 'GET']); $gather->say('To call the planet Brodo Asogi, press 2. To call the planet' . ' Dagobah, press 3. To call an Oober asteroid to your location,' . ' press 4. To go back to the main menu, press the star key', ['voice' => 'alice', 'language' => 'en-GB']); return $response; }
/** * Replies with a join call xml * * @return \Illuminate\Http\Response */ public function showJoin() { $response = new Twiml(); $response->say('You are about to join the Rapid Response conference.', ['voice' => 'alice', 'language' => 'en-GB']); $gather = $response->gather(['numDigits' => 1, 'action' => route('conference-connect', [], false), 'method' => 'GET']); $gather->say('Press 1 to join as a listener.'); $gather->say('Press 2 to join as a speaker.'); $gather->say('Press 3 to join as the moderator.'); return response($response)->header('Content-Type', 'application/xml'); }
/** * Handles the callback from screening a call * * @return \Illuminate\Http\Response */ public function screenCall(Request $request) { $customerPhoneNumber = $request->input('From'); $spelledPhoneNumber = join(',', str_split($customerPhoneNumber)); $response = new Twiml(); $gather = $response->gather(['numDigits' => 1, 'action' => route('connect-message', [], false), 'method' => 'GET']); $gather->say('You have an incoming call from: '); $gather->say($spelledPhoneNumber); $gather->say('Press any key to accept'); $response->say('Sorry. Did not get your response'); $response->hangup(); return $response; }
<?php // Create a route that will handle Twilio webhook requests, sent as an // HTTP POST to /voice in our application require_once '/path/to/vendor/autoload.php'; use Twilio\Twiml; // Use the Twilio PHP SDK to build an XML response $response = new Twiml(); // Use the <Gather> verb to collect user input $gather = $response->gather(array('numDigits' => 1, 'action' => '/gather')); // use the <Say> verb to request input from the user $gather->say('For sales, press 1. For support, press 2.'); // If the user doesn't enter input, loop $response->redirect('/voice'); // Render the response as XML in reply to the webhook request header('Content-Type: text/xml'); echo $response;
<?php // Create a route that will handle Twilio webhook requests, sent as an // HTTP POST to /voice in our application require_once '/path/to/vendor/autoload.php'; use Twilio\Twiml; // Use the Twilio PHP SDK to build an XML response $response = new Twiml(); // Use the <Gather> verb to collect user input $gather = $response->gather(array('numDigits' => 1)); // use the <Say> verb to request input from the user $gather->say('For sales, press 1. For support, press 2.'); // If the user doesn't enter input, loop $response->redirect('/voice'); // Render the response as XML in reply to the webhook request header('Content-Type: text/xml'); echo $response;