Skip to content

Instantly share code, notes, and snippets.

View twilioforkwc's full-sized avatar

Twilio for KDDI Web Communications twilioforkwc

View GitHub Profile
<Response>
<Say language="ja-jp">Twilioカンファレンスへようこそ!</Say>
<Dial>
<Conference>twilioConferenceRoom</Conference>
</Dial>
</Response>
<Response>
<Say language="ja-jp">Twilioカンファレンスへようこそ!</Say>
<Dial>
<Conference waitUrl="https://api.twilio.com/Cowbwell.mp3">twilioConferenceRoom</Conference>
</Dial>
</Response>
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Gather action="room-check.php" numDigits="4">
<Say language="ja-jp">ルーム番号を4桁で入力してください。</Say>
</Gather>
<!-- 入力に間違いがあるとリトライします。 -->
<Redirect />
</Response>
<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
$key = $_REQUEST['Digits'];
?>
<Response>
<?php
if ($key == '1234')
{
<?php
header("content-type: text/xml");
?>
<Response>
<?PHP if (empty($_POST["Digits"])): ?>
<Say language="ja-jp">サンタさんにメッセージをおくるには 1を, メッセージの再生は 2を, 押してください。</Say>
<Gather numDigits="1" timeout="30" />
<?PHP elseif ($_POST["Digits"] == "1"): ?>
<Say language="ja-jp">録音完了後, 電話器のボタンをどれか 押してください。</Say>
<Record action="santa.php" />
<?php
header("content-type: text/xml");
// Connect to MySQL, and connect to the Database
mysql_connect('DB URL', 'ID', 'PWD') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());
// 発信者番号を取得します。
$tel_from = $_POST['From'];
// 録音ファイルのURLを取得します。
<?php
header("content-type: text/xml");
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Say language="ja-jp">部署めいと名前を発話し、シャープを押してください</Say>
<Record maxLength="30" action="recorded.php" />
</Response>
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
require_once(dirname(__FILE__) . '/../lib/AmiDSRHTTP.class.php');
$buff = file_get_contents($_REQUEST['RecordingUrl']);
$amiVoice = new AmiDSRHTTP("http://Amivoice API URL/recognize","http://Amivoice API URL/Twilio/dialer/dialer.gram");
$result = $amiVoice->speechRecognition($buff);
if(!$result === false) {
# JSGF V1.0 UTF-8;
grammar dialer;
public <dialer> = ( <kanri> | <kaihatu> | <eigyou> ) [さん|くん|さま];
<kanri> = 管理本部 [の] ( 佐々木 | 佐藤 | 河野 ) ;
<kaihatu> = 開発本部 [の] (佐々木 | 田中 | 中村);
<eigyou> = 営業本部 [の] (西岡 | 山下 | 小林);
//addWord 管理本部 かんりほんぶ
//addWord 管理本部 かんりぶ
<?php
header("content-type: text/xml");
// 録音ファイルのURLを取得します。
$recording_url = $_POST['RecordingUrl'];
?>
<Response>
<Say language="ja-jp">録音ファイルを再生します。</Say>
<Play><?PHP echo $recording_url; ?></Play>
</Response>