private function _commandFor($question) { $voiceResponse = new \Services_Twilio_Twiml(); $voiceResponse->say($question->body); $voiceResponse->say($this->_messageForQuestion($question)); $voiceResponse = $this->_registerResponseCommand($voiceResponse, $question); return $voiceResponse; }
private function _messageAfterLastQuestion() { $voiceResponse = new \Services_Twilio_Twiml(); $voiceResponse->say('That was the last question'); $voiceResponse->say('Thank you for participating in this survey'); $voiceResponse->say('Good-bye'); $voiceResponse->hangup(); return $voiceResponse; }
public function twiml() { if (Input::has('code')) { $response = new \Services_Twilio_Twiml(); $response->say('Please enter the following code ' . (Config::get('app.domain') ? ' on ' . $this->getDomain() : '') . '.'); $response->say(implode(', ', str_split(Input::get('code')))); $response->say('Once again, your code is: '); $response->say(implode(', ', str_split(Input::get('code')))); print $response; } else { return false; } }
public function testRendererCanRenderViewModel() { $twiml = new \Services_Twilio_Twiml(); $twiml->say('Hello'); $model = new ViewModel(array('payload' => $twiml)); $test = $this->renderer->render($model); $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?><Response><Say>Hello</Say></Response>', str_replace("\n", "", $test)); }
/** * generateTwiML - Generates TwiML with passed text and music from url * * @param string $text - call message text * @param string|null $musicUrl - music url * @return string - generated XML * */ public function generateTwiML($text, $musicUrl = null, $musicOptions = array()) { $response = new Services_Twilio_Twiml(); $response->say($text); if (!empty($musicUrl)) { $response->play($musicUrl, $musicOptions); } return $response->__toString(); }
public function afterCallHook(Request $request) { $this->saveRecording($request); $this->notifyOwnerOfRecording($request); $this->notifyFriendsOfRecording($request); $response = new TwimlGenerator(); $response->say('Sorry, but we can\'t record more than an hour.'); $response->hangup(); event(new CallRecordingWasCompleted($request->all())); return $response; }
public function testValidMethodReturningTwimlOrStringIsCastToViewModel() { $twiml = new \Services_Twilio_Twiml(); $twiml->say('Hello'); $this->responder->getEventManager()->attach('getTwilioResponse', function ($e) use($twiml) { return $twiml; }); $this->request->setMethod('GET'); $result = $this->controller->onDispatch($this->event); $this->assertInstanceof('Synrg\\Twilio\\View\\TwilioModel', $result); $this->assertSame($twiml, $result->getResponse()); }
function generateResponse($to, $details) { $twiml_response = new Services_Twilio_Twiml(); $twiml_response->say("We are trying to connect you to our customer system."); if ($details['type'] == 'phone') { $twiml_response->dial($details['detail']['id'], array('callerId' => $to)); } else { if ($details['type'] == 'sip') { $headers = ''; if (isset($details['detail']['headers'])) { $headers = '?' . implode("&", array_map(function ($k, $v) { return "{$k}={$v}"; }, array_keys($details['detail']['headers']), $details['detail']['headers'])); } $dial = $twiml_response->dial(NULL, array('callerId' => $to)); $sip = $dial->sip(); $sip->uri("{$details['detail']['id']}@{$details['detail']['domain']}{$headers}"); } } $twiml_response->say("Thank you for calling us. Goodbye."); return (string) $twiml_response; }
public function process(Application $app, Request $request) { $pollDigits = $app['request']->get('Digits'); $Product = $app['eccube.repository.product']->get($pollDigits); $name = $Product->getName(); $say = $name . "に投票されました。ありがとうございました。"; $twiml = new \Services_Twilio_Twiml(); $twiml->say($say, array('language' => 'ja-jp')); $twiml->hangup(); $xml = strval($twiml); $response = new Response($app['twig']->render('TwilioPoll/Resource/template/xml.twig', array('xml' => $xml)), 200, array('Content-Type' => 'text/xml')); return $response; }
function connectCall() { global $sugar_config; ob_flush(); $callRecipient = $_REQUEST["callRecipient"]; $module_name = $_REQUEST['module_name']; $record_id = $_REQUEST['record_id']; $response = new Services_Twilio_Twiml(); $response->pause(5); $response->say('Now connecting you.'); $action = $sugar_config['site_url'] . "/index.php?entryPoint=twilio&action=callComplete&to_pdf=true&module_name={$module_name}&record_id={$record_id}"; $dialAttributes = array('record' => 'true', 'action' => $action); $response->dial($callRecipient, $dialAttributes); print $response; }
private function generateVoiceFile(&$file_id, &$group_id) { $file = $this->fm->find($file_id)->name; $group = $this->gm->find($group_id)->name; $url = base_url() . 'uploads/voice/' . $file; $response = new Services_Twilio_Twiml(); $response->say('Hello'); $response->play($url, array("loop" => 0)); //generated file $twiML = 'uploads/xml/' . $group . '_' . time() . '.xml'; $xml = fopen($twiML, 'w'); fwrite($xml, $response); fclose($xml); return base_url() . $twiML; }
<?php /** * ミニコールセンターサービスでキューイング時にメッセージを送出するwait.php * * @author rutoru * @package Twilio-MiniCC * @GitHub https://github.com/rutoru/Twilio-MiniCC */ // 設定クラス require_once 'Conf.php'; // Twilio Helperライブラリ(index.phpと同じ場所にServicesフォルダが存在する前提) require_once 'Services/Twilio.php'; // Twimlオブジェクト作成 $response = new Services_Twilio_Twiml(); // QueuePosition取得(数字のみにフィルタリング) $waitnumber = filter_input(INPUT_POST, 'QueuePosition', FILTER_SANITIZE_NUMBER_INT); // 待ち(短めの保留音を入れる予定) $response->pause('3'); // キューイングメッセージ送出 $response->say("お待たせしております。現在、" . $waitnumber . "番目にお待ちです。", array('language' => Conf::LANG)); // 保留音送出 $response->play(Conf::MOH_LONG); // TwiML作成 print $response;
public function test_alert() { $this->alertinator->twilio['fromNumber'] = '1234567890'; // One level that's exactly right. $alertees = ['email' => ['*****@*****.**', Alertinator::WARNING]]; $this->expectOutputEquals("Sending message foobaz to foo@example.com via email.\n", [$this->alertinator, 'alert'], [new AlertinatorWarningException('foobaz'), $alertees]); // Non-matching levels. $this->expectOutputEquals('', [$this->alertinator, 'alert'], [new AlertinatorCriticalException('foobaz'), $alertees]); // Multiple levels associated with an alerting method. $alertees = ['email' => ['*****@*****.**', Alertinator::WARNING | Alertinator::CRITICAL]]; $this->expectOutputEquals("Sending message foobaz to foo@example.com via email.\n", [$this->alertinator, 'alert'], [new AlertinatorWarningException('foobaz'), $alertees]); // Multiple methods. $alertees = ['email' => ['*****@*****.**', Alertinator::WARNING], 'sms' => ['1234567890', Alertinator::WARNING], 'call' => ['1234567890', Alertinator::WARNING]]; // Because Twilio doesn't allow you to just send along a message // directly, you have to create a url that returns the message. $twiml = new Services_Twilio_Twiml(); $twiml->say('foobaz'); $url = 'http://twimlets.com/echo?Twiml=' . urlencode($twiml); $this->expectOutputEquals("Sending message foobaz to foo@example.com via email.\n" . "Sending message foobaz to 1234567890 via sms.\n" . "Sending message from {$url} to +11234567890 via call.\n", [$this->alertinator, 'alert'], [new AlertinatorWarningException('foobaz'), $alertees]); }
public function process_poll($randomid, $sch_id) { $this->load->model(array('reply_status_model', 'schedule_model')); $digit = isset($_REQUEST['Digits']) ? $_REQUEST['Digits'] : null; $reply_rows = $this->reply_status_model->get_rows(array()); foreach ($reply_rows as $reply_row) { if ($reply_row->number == $digit) { $flag = true; $this->reply_status_model->updateReplyStatus($digit, $randomid); $this->schedule_model->set_reply_status_id($digit, $sch_id); $this->schedule_model->set_onsite_status_id($digit, $sch_id); break; } else { $flag = false; } } if ($flag == false) { $say = "Sorry, You have choosen incorrect availability"; } else { $say = "Thank you. We have marked your availability"; } $response = new Services_Twilio_Twiml(); $response->say($say); $response->hangup(); header('Content-Type: text/xml'); print $response; }
} session_start(); $_SESSION['engineer_accepted_call'] = false; $pagerduty = new \Vend\Phoneduty\Pagerduty($APItoken, $serviceAPItoken, $domain); $userID = $pagerduty->getOncallUserForSchedule($scheduleID); $user = $pagerduty->getUserDetails($userID); $twilio = new Services_Twilio_Twiml(); $attributes = array('voice' => 'alice', 'language' => $language); if (isset($_POST['Digits'])) { if ($_POST['Digits'] != '') { $_SESSION['end_user_confirmed_call'] = True; } } if (!isset($_SESSION['end_user_confirmed_call']) and strtolower($validate_human) == 'true') { if ($greeting != '') { $twilio->say($greeting, $attributes); $_SESSION['caller_greeted'] = True; } $gather = $twilio->gather(array('timeout' => 25, 'numDigits' => 1)); $gather->say("Press 1 to reach the on-call engineer.", $attributes); $twilio->say("Goodbye.", $attributes); $twilio->hangup(); } else { if ($greeting != '') { if (!isset($_SESSION['caller_greeted'])) { $twilio->say($greeting, $attributes); $_SESSION['caller_greeted'] = True; } } if ($user !== null) { $time = "";
<?php require 'twilio-php-master/Services/Twilio.php'; $response = new Services_Twilio_Twiml(); $response->say('Liz Holzman'); $response->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5)); print $response;
<?php require "Services/Twilio.php"; $response = new Services_Twilio_Twiml(); $out_tel_to = "転送先電話番号"; $sound_url_s1 = "一段目に水をはって火にかける。フラワーウォータの出来上がり!.mp3"; if (empty($_POST["Digits"])) { $gather = $response->gather(array('numDigits' => 1, 'timeout' => 30)); $gather->say("Twilioへようこそ。モロッコのお母さんのレシピが知りたい方は1を。電話の転送は2を。社会人3年目の方は3を。電話の終了は4をおしてください。", array('language' => 'ja-jp')); } elseif ($_POST["Digits"] == "1") { $response->play($sound_url, array("loop" => 1)); $gather = $response->gather(array('numDigits' => 1, 'timeout' => 30)); } elseif ($_POST["Digits"] == "2") { $response->dial($out_tel_to); $gather = $response->gather(array('numDigits' => 1, 'timeout' => 30)); } elseif ($_POST["Digits"] == "3") { $response->say("社会人3年目の方、楽しいデモへようこそ。", array('language' => 'ja-jp')); } elseif ($_POST["Digits"] == "4") { $response->say("楽しいデモのご利用ありがとうございました。", array('language' => 'ja-jp')); } print $response;
$body = "You have a new voicemail from " . $from . "\n\n"; $body .= "Text of the transcribed voicemail:\n{$_REQUEST['TranscriptionText']}.\n\n"; $body .= "Click this link to listen to the message:\n{$_REQUEST['RecordingUrl']}.mp3"; mail($myemail, "New Voicemail Message from " . $from, $body, $headers); die; break; case "failed": $body = "You have a new voicemail from " . $from . "\n\n"; $body .= "Click this link to listen to the message:\n{$_REQUEST['RecordingUrl']}.mp3"; mail($myemail, "New Voicemail Message from " . $from, $body, $headers); die; break; } } else { if (isset($_REQUEST['RecordingUrl'])) { $response->say("Thanks. Good bye."); $response->hangup(); if (isset($transcribe) && strtolower($transcribe) != 'true') { $body = "You have a new voicemail from " . $from . "\n\n"; $body .= "Click this link to listen to the message:\n{$_REQUEST['RecordingUrl']}.mp3"; mail($myemail, "New Voicemail Message from " . $from, $body, $headers); } } else { $response->say($message); if ($transcribe) { $params = array("transcribe" => "true", "transcribeCallback" => "voicemail.php"); } else { $params = array(); } $response->record($params); }
<?php /** * A simple call recorder for iphone based on twilio */ require __DIR__ . '/vendor/autoload.php'; $response = new Services_Twilio_Twiml(); $response->say("This call is being recorded"); //notify both parties //when both parties hang up, twill will post the recording to the action URL $response->record(array('action' => 'save_recording.php', 'method' => 'POST', 'playBeep' => true)); $response->hangup(); print $response;
function testGeneration() { $r = new Services_Twilio_Twiml(); $r->say('hello'); $r->dial()->number('123', array('sendDigits' => '456')); $r->gather(array('timeout' => 15)); $doc = simplexml_load_string($r); $this->assertEquals('Response', $doc->getName()); $this->assertEquals('hello', (string) $doc->Say); $this->assertEquals('456', (string) $doc->Dial->Number['sendDigits']); $this->assertEquals('123', (string) $doc->Dial->Number); $this->assertEquals('15', (string) $doc->Gather['timeout']); }
while ($res = mysql_fetch_assoc($d)) { $numbers[] = array('id' => $res['id'], 'number' => $res['number'], 'timeout' => $res['timeout'], 'order' => $res['order']); } // Get config values $config = array(); $d = select_query('mod_twilio_config', '*', array()); while ($res = mysql_fetch_assoc($d)) { $setting = $res['setting']; $value = $res['val']; $config[$setting] = $value; } $resp = new Services_Twilio_Twiml(); if (!isset($_REQUEST['step'])) { $resp = new Services_Twilio_Twiml(); if ($config['intro_mode'] == 'text') { $resp->say($config['intro_text']); } else { $resp->play('get_audio.php?f=intro_file'); } $gather = $resp->gather(array('timeout' => $config['gather_timeout'], 'numDigits' => '1', 'action' => 'call_handler.php?step=1')); if ($config['invalid_request_mode'] == 'text') { $resp->say($config['invalid_request_text']); } else { $resp->play('get_audio.php?f=invalid_request_file'); } $resp->redirect('call_handler.php'); } elseif ($_REQUEST['step'] == '1') { if ($_REQUEST['Digits'] == '1') { $_SESSION['type'] = 'ticket'; if ($config['step1_ticket_mode'] == 'text') { $resp->say($config['step1_ticket_text']);
<?php require_once 'vendor/autoload.php'; require 'db.php'; require_once 'speechtotext.php'; $response = new Services_Twilio_Twiml(); $say_str = "ご利用ありがとうございました"; $recording_url = $_REQUEST['RecordingUrl']; $id = $_REQUEST['id']; $data = json_decode(getDocument($id), true); $data['recording_url'] = $recording_url; $speechtext = speechtotext($recording_url); $data['speechtext'] = $speechtext['results'][0]['alternatives'][0]['transcript']; update($data); $response = new Services_Twilio_Twiml(); $response->say($say_str, array('language' => 'ja-jp')); $response->hangup(); header("Content-type: text/xml"); print $response;
<?php // Get the PHP helper library from twilio.com/docs/php/install // this line loads the library require_once '/path/to/vendor/autoload.php'; $response = new Services_Twilio_Twiml(); $response->say("hello world!", array('voice' => 'alice')); print $response;
/** * * @return Services_Twilio object */ public static function generateTwiML($message = '') { $response = new Services_Twilio_Twiml(); $response->say($message); return $response; }
* * (c) 2014 Vend Ltd. * */ require __DIR__ . '/../vendor/autoload.php'; // Set these Heroku config variables $scheduleID = getenv('PAGERDUTY_SCHEDULE_ID'); $APItoken = getenv('PAGERDUTY_API_TOKEN'); $domain = getenv('PAGERDUTY_DOMAIN'); // Should we announce the local time of the on-call person? // (helps raise awareness you might be getting somebody out of bed) $announceTime = getenv('PHONEDUTY_ANNOUNCE_TIME'); $pagerduty = new \Vend\Phoneduty\Pagerduty($APItoken, $domain); $userID = $pagerduty->getOncallUserForSchedule($scheduleID); if (null !== $userID) { $user = $pagerduty->getUserDetails($userID); $attributes = array('voice' => 'alice', 'language' => 'en-GB'); $time = ""; if ($announceTime && $user['local_time']) { $time = sprintf("The current time in their timezone is %s.", $user['local_time']->format('g:ia')); } $twilioResponse = new Services_Twilio_Twiml(); $response = sprintf("The current on-call engineer is %s. %s " . "Please hold while we connect you.", $user['first_name'], $time); $twilioResponse->say($response, $attributes); $twilioResponse->dial($user['phone_number'], $attributes); // send response if (!headers_sent()) { header('Content-type: text/xml'); } echo $twilioResponse; }
include 'company-directory-map.php'; $error = false; if (isset($_REQUEST['Digits'])) { $digits = $_REQUEST['Digits']; } else { $digits = ''; } if (strlen($digits)) { $result = getPhoneNumberByDigits($digits); if ($result != false) { $number = getPhoneNumberByExtension($result['extension']); $r = new Services_Twilio_Twiml(); $r->say($result['name'] . "'s extension is " . $result['extension'] . " Connecting you now"); $r->dial($number); header("Content-Type:text/xml"); print $r; exit; } else { $error = true; } } $r = new Services_Twilio_Twiml(); if ($error) { $r->say("No match found for {$digits}"); } $g = $r->gather(); $g->say("Enter the first several digits of the last name of the party you wish to reach, followed by the pound sign"); $r->say("I did not receive a response from you"); $r->redirect("company-directory.php"); header("Content-Type:text/xml"); print $r;
function getGreeting() { $response = new Services_Twilio_Twiml(); $response->say('Hi there, Thanks for Calling Click Pick. It\'s easy to save money on click hyphen pick.com . Please leave us a feedback at Admin at dealsign.net.'); echo $response; }
<?php // Get the PHP helper library from twilio.com/docs/php/install // this line loads the library require '/path/to/twilio-php/Services/Twilio.php'; $response = new Services_Twilio_Twiml(); // get the phone number from the page request parameters, if given if (isset($_REQUEST['To'])) { $number = htmlspecialchars($_REQUEST['To']); $response->dial(array('callerId' => '+15017250604'))->number($number); } else { $response->say("Thanks for calling!"); } echo $response;
try { // INSERT $db = new Database(); $stmt = $db->getPdo()->prepare('INSERT INTO `queue_data`(`CallSid`, `From`, `To`, `CallStatus`, `ApiVersion`, `Direction`, `ForwardedFrom`, `CallerName`, `QueueSid`, `QueueTime`, `DequeingCallSid`, `Time`)' . ' VALUES (:CallSid,:From,:To,:CallStatus,:ApiVersion,:Direction,:ForwardedFrom,:CallerName,' . ':QueueSid,:QueueTime,:DequeingCallSid,NOW())'); // Standard Parameters $stmt->bindValue(':CallSid', filter_input(INPUT_POST, 'CallSid')); $stmt->bindValue(':From', filter_input(INPUT_POST, 'From')); $stmt->bindValue(':To', filter_input(INPUT_POST, 'To')); $stmt->bindValue(':CallStatus', filter_input(INPUT_POST, 'CallStatus')); $stmt->bindValue(':ApiVersion', filter_input(INPUT_POST, 'ApiVersion')); $stmt->bindValue(':Direction', filter_input(INPUT_POST, 'Direction')); $stmt->bindValue(':ForwardedFrom', filter_input(INPUT_POST, 'ForwardedFrom')); $stmt->bindValue(':CallerName', filter_input(INPUT_POST, 'CallerName')); // Queue Parameters $stmt->bindValue(':QueueSid', filter_input(INPUT_POST, 'QueueSid')); $stmt->bindValue(':QueueTime', filter_input(INPUT_POST, 'QueueTime')); $stmt->bindValue(':DequeingCallSid', filter_input(INPUT_POST, 'DequeingCallSid')); $stmt->execute(); } catch (Exception $e) { // デバッグモード時はエラーメッセージ表示 // 運用時はデータ取得に失敗しても、オペレータに接続 if (Conf::DEBUG) { echo $e->getMessage(); } } // Twimlオブジェクト作成 $response = new Services_Twilio_Twiml(); // キューイングメッセージ送出 $response->say("オペレータにおつなぎします。", array('language' => Conf::LANG)); // TwiML作成 print $response;
<?php require __DIR__ . '/../vendor/autoload.php'; if (isset($_POST['ParentCallSid'])) { session_id($_POST['ParentCallSid']); } session_start(); // What language should Twilio use? $language = getenv('TWILIO_LANGUAGE'); $attributes = array('voice' => 'alice', 'language' => $language); $twilio = new Services_Twilio_Twiml(); if (isset($_POST['Digits'])) { if ($_POST['Digits'] != '') { $_SESSION['engineer_accepted_call'] = true; $twilio->say("Connecting", $attributes); } } else { $twilio->pause(array('length' => 2)); $gather = $twilio->gather(array('timeout' => 10, 'numDigits' => 1)); $gather->say("Press 1 to accept this call.", $attributes); $twilio->say("Goodbye.", $attributes); $twilio->hangup(); } // send response if (!headers_sent()) { header('Content-type: text/xml'); } echo $twilio;