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));
 }
 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;
 }
示例#3
0
 /**
  * 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();
 }
 private function respond($smsResponse, $reservation)
 {
     $response = new TwilioTwiml();
     $response->message($smsResponse);
     if (!is_null($reservation)) {
         $response->message('Your reservation has been ' . $reservation->status . '.', ['to' => $reservation->respond_phone_number]);
     }
     return $response;
 }
示例#5
0
 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());
 }
示例#7
0
 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 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;
 }
示例#9
0
 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;
 }
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;
}
示例#11
0
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("&amp;", 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;
}
 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;
 }
示例#13
0
<?php

include "config.php";
require 'Services/Twilio.php';
# Tell Twilio to expect some XML
header('Content-type: text/xml');
# Create response object.
$response = new Services_Twilio_Twiml();
# Dial into the Queue we placed the caller into to connect agent to
# first person in the Queue.
$dial = $response->dial();
$dial->queue($callqueue);
# Print TwiML
print $response;
示例#14
0
 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]);
 }
<?php

require __DIR__ . '/../vendor/autoload.php';
if (isset($_POST['CallSid'])) {
    session_id($_POST['CallSid']);
}
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['DialCallStatus'])) {
    if ($_POST['DialCallStatus'] == 'completed') {
        if ($_SESSION['engineer_accepted_call']) {
            error_log("engineer_accepted_call is true");
            $twilio->hangup();
        }
    }
}
$twilio->redirect('voicemail.php');
// send response
if (!headers_sent()) {
    header('Content-type: text/xml');
}
echo $twilio;
示例#16
0
 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;
 }
示例#17
0
<?php

session_start();
include 'Services/Twilio.php';
include "config.php";
$client = new Services_Twilio($accountsid, $authtoken);
$response = new Services_Twilio_Twiml();
$timeout = 20;
$phonenumbers = array('1234567890', '1234567891');
$dial = $response->dial(NULL, array('callerId' => $fromNumber));
foreach ($phonenumbers as $number) {
    $dial->number($number);
}
header("Content-Type:text/xml");
print $response;
示例#18
0
// (helps raise awareness you might be getting somebody out of bed)
$announceTime = getenv('PHONEDUTY_ANNOUNCE_TIME');
// What language should Twilio use?
$language = getenv('TWILIO_LANGUAGE');
// Should we record the conversation once connected to the on-call person?
// https://www.twilio.com/docs/api/twiml/dial#attributes-record
$record = getenv('TWILIO_RECORD');
if (isset($_POST['CallSid'])) {
    session_id($_POST['CallSid']);
}
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();
<?php

// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/twilio-php/Services/Twilio.php';
// Loads the library
$response = new Services_Twilio_Twiml();
$response->enqueue('Queue Demo');
print $response;
<?php

require_once 'vendor/autoload.php';
$response = new Services_Twilio_Twiml();
$gather = $response->gather(array('action' => 'http://' . $_SERVER['SERVER_NAME'] . '/process_needs.php', 'method' => 'GET', 'timeout' => '30', 'numDigits' => '1'));
$gather->say("お電話ありがとうございます。こちらは豊島区被災者ニーズ申請サービスです。着るもので困っている場合は1を、食べるもので困っている場合は2を、住むところで困っている場合は3を、病気で困っている場合は4を、帰宅が困難になっている人は5を押してください", array('language' => 'ja-jp'));
header("Content-type: text/xml");
print $response;
示例#21
0
 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

/**
* 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;
示例#23
0
<?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;
示例#24
0
 *
 * (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;
}
示例#25
0
<?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_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;
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;
示例#28
0
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;
示例#29
0
<?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;