private function _redirectToQuestion($question, $route) { $questionUrl = route($route, ['question' => $question->id, 'survey' => $question->survey->id]); $redirectResponse = new Twiml(); $redirectResponse->redirect($questionUrl, ['method' => 'GET']); return response($redirectResponse); }
/** * Responds with message announcing return to the main menu * @return Services_Twilio_Twiml */ public function showMainMenuRedirect() { $errorResponse = new Twiml(); $errorResponse->say('Returning to the main menu', ['voice' => 'alice', 'language' => 'en-GB']); $errorResponse->redirect(route('welcome', [], false)); return $errorResponse; }
/** * Responds with a <Dial> to the caller's planet * * @return \Illuminate\Http\Response */ public function showPlanetConnection(Request $request) { $response = new Twiml(); $response->say($this->_thankYouMessage, ['voice' => 'Alice', 'language' => 'en-GB']); $response->say("You'll be connected shortly to your planet", ['voice' => 'Alice', 'language' => 'en-GB']); $planetNumbers = ['2' => '+12024173378', '3' => '+12027336386', '4' => '+12027336637']; $selectedOption = $request->input('Digits'); $planetNumberExists = isset($planetNumbers[$selectedOption]); if ($planetNumberExists) { $selectedNumber = $planetNumbers[$selectedOption]; $response->dial($selectedNumber); return $response; } else { $errorResponse = new Twiml(); $errorResponse->say('Returning to the main menu', ['voice' => 'Alice', 'language' => 'en-GB']); $errorResponse->redirect(route('welcome', [], false)); return $errorResponse; } }
<?php // NOTE: This example uses the next generation Twilio helper library - for more // information on how to download and install this version, visit // https://www.twilio.com/docs/libraries/php require_once '/path/to/vendor/autoload.php'; use Twilio\Twiml; $response = new Twiml(); $response->say("You will now be connected to the first caller in the queue."); $dial = $response->dial(); $dial->queue("Queue Demo"); $response->redirect(); 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, '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;