<?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;
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;
 public function testRedirectAddAttribute()
 {
     $r = new Services_Twilio_Twiml();
     $r->redirect(array("foo" => "bar"));
     $expected = '<Response><Redirect foo="bar"></Redirect></Response>';
     $this->assertXmlStringEqualsXmlString($expected, $r);
 }
예제 #4
0
}
$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']);
        } else {
            $resp->play('get_audio.php?f=step1_ticket_file');
        }
        $gather = $resp->gather(array('timeout' => $config['gather_timeout'], 'finishOnKey' => '#', 'action' => 'call_handler.php?step=2'));
        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');
예제 #5
0
// 入力値を表示には使わないので、デフォルトでフィルタするのみ。
if (filter_input(INPUT_POST, 'Digits') !== NULL) {
    $input = filter_input(INPUT_POST, 'Digits');
    // DTMF入力判定
    switch ($input) {
        case '1':
            // 1の場合はオペレータに接続
            $response->say('オペレータにおつなぎします。しばらくお待ちください。', array('language' => Conf::LANG));
            // Queueに入れる
            // 待ちが発生した場合は、waitUrl呼び出し
            $response->enqueue(Conf::QUEUE, array('waitUrl' => 'wait.php', 'action' => $enqueue_action_url, 'method' => Conf::METHOD));
            break;
        case '2':
            // 2の場合は情報を提供する
            // XMLファイル呼び出し
            $response->redirect('information.xml');
            break;
        default:
            // 1,2以外の場合は再入力
            $gather = $response->gather(array('numDigits' => 1, 'timeout' => '10', 'method' => 'POST'));
            $gather->say('再度入力をお願いします。' . 'お問い合わせは1を、' . '最新の製品情報をお聞きになりたい場合は2を押してください。', array('language' => Conf::LANG));
            // タイムアウトとなった場合はオペレータに接続
            $response->say('入力が確認できませんでした。オペレータにおつなぎします。しばらくお待ちください。', array('language' => Conf::LANG));
            $response->enqueue(Conf::QUEUE, array('waitUrl' => 'wait.php', 'action' => $enqueue_action_url, 'method' => Conf::METHOD));
            break;
    }
} else {
    try {
        // 発信電話番号を取得し、DB照会
        $db = new Database();
        $stmt = $db->getPdo()->prepare('SELECT telnum FROM operators WHERE telnum = :ani');
예제 #6
0
<?php

/**
 * オペレータにQueueを提供するoperator_queue.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();
// キューに入れる=受電開始
$response->say("キューにはいりました。", array('language' => Conf::LANG));
$dial = $response->dial();
$dial->queue(Conf::QUEUE, array('url' => 'guidance.php', Conf::METHOD));
// オペレータは繰り返し受電
$response->redirect();
// TwiML作成
print $response;