Esempio n. 1
1
<?php

// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require 'vendor/autoload.php';
use Twilio\Twiml;
$response = new Twiml();
$response->say("Hello! You will get an SMS message soon.");
$response->sms("This is the ship that made the Kessel Run in fourteen parsecs?");
print $response;
 /**
  * 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;
 }
 public function showPlay(Request $request)
 {
     $recordingUrl = $request->input('recording_url');
     $response = new Twiml();
     $response->play($recordingUrl);
     return response($response)->header('Content-Type', 'application/xml');
 }
 public function showHangup()
 {
     $response = new Twiml();
     $response->say('Your recording has been saved. Good bye.', ['voice' => 'alice', 'language' => 'en-GB']);
     $response->hangup();
     return response($response)->header('Content-Type', 'application/xml');
 }
 private function _commandForVoice($question)
 {
     $voiceResponse = new Twiml();
     $voiceResponse->say($question->body);
     $voiceResponse->say($this->_messageForVoiceQuestion($question));
     $voiceResponse = $this->_registerResponseCommand($voiceResponse, $question);
     return response($voiceResponse);
 }
 /**
  * Manage the subscription for a subscriber.
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $phoneNumber = $request->input('From');
     $message = $request->input('Body');
     $outputMessage = $this->createMessage($phoneNumber, $message);
     $response = new Twiml();
     $response->message($outputMessage);
     return response($response)->header('Content-Type', 'text/xml');
 }
 private function respond($smsResponse, $reservation)
 {
     $response = new Twiml();
     $response->message($smsResponse);
     if (!is_null($reservation)) {
         $response->message('Your reservation has been ' . $reservation->status . '.', ['to' => $reservation->respond_phone_number]);
     }
     return $response;
 }
 /**
  * Process a new call
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function newCall(Request $request)
 {
     $response = new Twiml();
     $callerIdNumber = config('services.twilio')['number'];
     $dial = $response->dial(['callerId' => $callerIdNumber]);
     $phoneNumberToDial = $request->input('phoneNumber');
     if (isset($phoneNumberToDial)) {
         $dial->number($phoneNumberToDial);
     } else {
         $dial->client('support_agent');
     }
     return $response;
 }
 /**
  * Endpoint which store a new lead with its lead source and forward the call
  *
  * @param  Request $request Input data
  * @return Response Twiml to redirect call to the forwarding number
  */
 public function store(Request $request)
 {
     $leadSource = LeadSource::where(['number' => $request->input('To')])->first();
     $lead = new Lead();
     $lead->leadSource()->associate($leadSource->id);
     $lead->city = $this->_normalizeName($request->input('FromCity'));
     $lead->state = $this->_normalizeName($request->input('FromState'));
     $lead->caller_number = $request->input('From');
     $lead->caller_name = $request->input('CallerName');
     $lead->call_sid = $request->input('CallSid');
     $lead->save();
     $forwardMessage = new Twiml();
     $forwardMessage->dial($leadSource->forwarding_number);
     return response($forwardMessage, 201)->header('Content-Type', 'application/xml');
 }
 /**
  * Responds with a <Dial> to the caller's planet
  *
  * @return \Illuminate\Http\Response
  */
 public function showExtensionConnection(Request $request)
 {
     $selectedOption = $request->input('Digits');
     try {
         $agent = $this->_getAgentForDigit($selectedOption);
     } catch (ModelNotFoundException $e) {
         return redirect()->route('main-menu-redirect');
     }
     $numberToDial = $agent->phone_number;
     $response = new Twiml();
     $response->say("You'll be connected shortly to your planet. " . $this->_thankYouMessage, ['voice' => 'alice', 'language' => 'en-GB']);
     $dialCommand = $response->dial(['action' => route('agent-voicemail', ['agent' => $agent->id], false), 'method' => 'POST']);
     $dialCommand->number($numberToDial, ['url' => route('screen-call', [], false)]);
     return $response;
 }
 /**
  * Replies with a call connect xml
  *
  * @return \Illuminate\Http\Response
  */
 public function showConnect(Request $request)
 {
     $muted = false;
     $moderator = false;
     $digits = $request->input('Digits');
     if ($digits === '1') {
         $muted = true;
     }
     if ($digits === '3') {
         $moderator = true;
     }
     $response = new Twiml();
     $response->say('You have joined the conference.', ['voice' => 'alice', 'language' => 'en-GB']);
     $dial = $response->dial();
     $dial->conference('RapidResponseRoom', ['startConferenceOnEnter' => $moderator, 'endConferenceOnExit' => $moderator, 'muted' => $muted, 'waitUrl' => 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient']);
     return response($response)->header('Content-Type', 'application/xml');
 }
Esempio n. 13
0
<?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;
Esempio n. 14
0
<?php

// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php';
// Loads the library
use Twilio\Twiml;
$response = new Twiml();
$body = $_REQUEST['Body'];
if ($body == 'hello') {
    $response->message('Hi!');
} else {
    if ($body == 'bye') {
        $response->message('Goodbye');
    }
}
print $response;
 private function _smsMessageAfterLastQuestion()
 {
     $messageResponse = new Twiml();
     $messageResponse->message("That was the last question.\n" . "Thank you for participating in this survey.\n" . 'Good bye.');
     return response($messageResponse)->withCookie(Cookie::forget('survey_session'))->withCookie(Cookie::forget('current_question'));
 }
Esempio n. 16
0
<?php

// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require_once '/path/to/vendor/autoload.php';
use Twilio\Twiml;
$response = new Twiml();
$response->say("hello world!", array('voice' => 'alice'));
print $response;
Esempio n. 17
0
<?php

// Download the library and copy into the folder containing this file.
require_once '/path/to/vendor/autoload.php';
// Loads the library
use Twilio\Twiml;
$response = new Twiml();
$response->enqueue(["workflowSid" => "WW0123456789abcdef0123456789abcdef"])->task("{'account_number':'12345abcdef'}");
print $response;
?>

<!-- alternatively -->

<?php 
$workflowSid = "WW0123456789abcdef0123456789abcdef";
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
    <Enqueue workflowSid="<?php 
echo $workflowSid;
?>
">
        <Task>{"account_number": "12345abcdef"}</Task>
    </Enqueue>
</Response>
Esempio n. 18
0
<?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->dial()->queue('Queue Demo');
echo $response;
Esempio n. 19
0
<?php

// Download the library and copy into the folder containing this file.
require_once '/path/to/vendor/autoload.php';
// Loads the library
use Twilio\Twiml;
$response = new Twiml();
$response->enqueue(array('workflowSid' => 'WW0123456789abcdef0123456789abcdef'));
print $response;
?>

<!-- alternatively -->

<?php 
$workflowSid = "WW0123456789abcdef0123456789abcdef";
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
    <Enqueue workflowSid="<?php 
echo $workflowSid;
?>
"/>
</Response>
<?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->enqueue('Queue Demo');
echo $response;
Esempio n. 21
0
<?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;
Esempio n. 22
0
<?php

// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require_once '/path/to/vendor/autoload.php';
use Twilio\Twiml;
// Update with your own phone number in E.164 format
$MODERATOR = '+15558675309';
$response = new Twiml();
// Start with a <Dial> verb
$dial = $response->dial();
// If the caller is our MODERATOR, then start the conference when they
// join and end the conference when they leave
if ($_REQUEST['From'] == $MODERATOR) {
    $dial->conference('My conference', array('startConferenceOnEnter' => True, 'endConferenceOnExit' => True));
} else {
    // Otherwise have the caller join as a regular participant
    $dial->conference('My conference', array('startConferenceOnEnter' => False));
}
print $response;
Esempio n. 23
0
<?php

// Get the PHP helper library from twilio.com/docs/php/install
require_once 'vendor/autoload.php';
// Loads the library
use Twilio\Twiml;
$response = new Twiml();
$message = $response->message();
$message->body("The Robots are coming! Head for the hills!");
$message->media("https://farm8.staticflickr.com/7090/6941316406_80b4d6d50e_z_d.jpg");
print $response;
 /**
  * Says message during connection between agent and customer (ET)
  *
  * @return \Illuminate\Http\Response
  */
 public function showConnectMessage(Request $request)
 {
     $response = new Twiml();
     $response->say('Connecting you to the extraterrestrial in distress');
     return $response;
 }
<?php

// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php';
// Loads the library
use Twilio\Twiml;
$response = new Twiml();
$response->message("The Robots are coming! Head for the hills!");
print $response;
<?php

// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require 'vendor/autoload.php';
use Twilio\Twiml;
$response = new Twiml();
$response->say("Thanks for calling!");
echo $response;
Esempio n. 27
0
<?php

// Download the library and copy into the folder containing this file.
require_once '/path/to/vendor/autoload.php';
// Loads the library
use Twilio\Twiml;
$response = new Twiml();
$response->enqueue(array('workflowSid' => 'WW0123456789abcdef0123456789abcdef', 'waitUrl' => '/hold_music.php', 'action' => '/post_bridge_survey.php'))->task("{'account_number':'12345abcdef'}");
print $response;
?>

<!-- alternatively -->

<?php 
$workflowSid = "WW0123456789abcdef0123456789abcdef";
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
    <Enqueue workflowSid="<?php 
echo $workflowSid;
?>
" , waitUrl="/hold_music.php" ,
             action="/post_bridge_survey.php">
        <Task>{"account_number": "12345abcdef"}</Task>
    </Enqueue>
</Response>
<?php

// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require 'vendor/autoload.php';
use Twilio\Twiml;
$response = new Twiml();
// get the phone number from the page request parameters, if given
if (isset($_REQUEST['To'])) {
    $number = htmlspecialchars($_REQUEST['To']);
    $dial = $response->dial(array('callerId' => '+15017250604'));
    // wrap the phone number or client name in the appropriate TwiML verb
    // by checking if the number given has only digits and format symbols
    if (preg_match("/^[\\d\\+\\-\\(\\) ]+\$/", $number)) {
        $dial->number($number);
    } else {
        $dial->client($number);
    }
} else {
    $response->say("Thanks for calling!");
}
echo $response;
<?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;
Esempio n. 30
0
<?php

// Download the library and copy into the folder containing this file.
require_once '/path/to/vendor/autoload.php';
// Loads the library
use Twilio\Twiml;
$response = new Twiml();
$response->enqueue(array('workflowSid' => 'WW0123456789abcdef0123456789abcdef'))->task("{'account_number':'12345abcdef'}", array('priority' => 5, 'timeout' => 200));
print $response;
?>

<!-- alternatively -->

<?php 
$workflowSid = "WW0123456789abcdef0123456789abcdef";
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
    <Enqueue workflowSid="<?php 
echo $workflowSid;
?>
">
        <Task priority="5" , timeout="200">{"account_number": "12345abcdef"}</Task>
    </Enqueue>
</Response>