public static function audioSpeechPicker($name = 'audioSpeechPicker') { $value = AppletInstance::getAudioSpeechPickerValue($name); $mode = null; $say = null; $play = null; if (preg_match('/^http(s)?:\\/\\//i', $value) || preg_match('/^vbx-audio-upload:\\/\\//i', $value)) { $mode = 'play'; $play = $value; } else { if (!empty($value)) { $mode = 'say'; $say = $value; } } $widget = new AudioSpeechPickerWidget($name, $mode, $say, $play); return $widget->render(); }
<h2 class="vbx-content-heading">Voicemail</h2> </div><!-- .vbx-content-menu --> <div class="voicemail-blank <?php echo empty($voicemail_say) && empty($voicemail_play) ? '' : 'hide'; ?> "> <h2>Hey, you haven’t setup your voicemail!</h2> <p>Change your greeting to: read text, play an audio file, or record it from your phone.</p> </div> <div class="vbx-content-container"> <div class="vbx-content-section"> <div class="vbx-form"> <h3>Voicemail</h3> <div class="voicemail-container"> <div class="voicemail-icon standard-icon"><span class="replace">Voicemail</span></div> <div class="voicemail-label">Greeting</div> <div class="voicemail-picker"> <?php $widget = new AudioSpeechPickerWidget('voicemail', $voicemail_mode, $voicemail_say, $voicemail_play, 'user_id:' . $this->session->userdata('user_id')); echo $widget->render(); ?> </div> </div><!-- .voicemail-container --> </div> </div><!-- .vbx-content-section --> </div><!-- .vbx-content-container --> </div><!-- .vbx-content-main -->
<?php header("Content-type: text/xml\n"); error_reporting(E_NONE); include "chirbit.php"; $user = AppletInstance::getUserGroupPickerValue('chirbit-controller'); $user_id = $user->values["id"]; $chirbit_username = PluginStore::get("chirbit_username_{$user_id}", ""); $chirbit_password = PluginStore::get("chirbit_password_{$user_id}", ""); $prompt = AppletInstance::getAudioSpeechPickerValue('prompt'); $after = AppletInstance::getAudioSpeechPickerValue('after'); $title = AppletInstance::getValue("title", ""); $response = new Response(); if (isset($_REQUEST['RecordingUrl'])) { chirbit_post($chirbit_username, $chirbit_password, $_REQUEST['RecordingUrl'], $title); $verb = AudioSpeechPickerWidget::getVerbForValue($after, null); $response->append($verb); $response->addHangup(); } else { $verb = AudioSpeechPickerWidget::getVerbForValue($prompt, null); $response->append($verb); $response->addRecord(); } $response->Respond();
// Note that we'd like to go through the machine again with our new state $keepLooping = true; } break; case DIAL_STATE_HANGUP: $response->addHangup(); break; case DIAL_STATE_NO_ANSWER: if ($dial_whom_selector == 'number') { if (empty($no_answer_redirect_number)) { $response->addHangup(); } $response->addRedirect($no_answer_redirect_number); } else { if ($no_answer_action === 'voicemail') { $response->append(AudioSpeechPickerWidget::getVerbForValue($voicemail, new Say("Please leave a message."))); $response->addRecord(array('transcribe' => true, 'transcribeCallback' => site_url('twiml/transcribe'))); $state[DIAL_ACTION] = DIAL_STATE_RECORDING; } else { if ($no_answer_action === 'redirect') { if (empty($no_answer_redirect)) { $response->addHangup(); } $response->addRedirect($no_answer_redirect); } else { if ($no_answer_action === 'hangup') { $response->addHangup(); } else { trigger_error("Unexpected no_answer_action"); } }
public function addMessage($response, $name, $fallback) { $message = AppletInstance::getAudioSpeechPickerValue($name); $response->append(AudioSpeechPickerWidget::getVerbForValue($message, new Say($fallback))); return $response; }
$zendesk_user = $CI->db->get_where('plugin_store', array('key' => 'zendesk_user'))->row(); $zendesk_user = json_decode($zendesk_user->value); define('ZENDESK_URL', $zendesk_user->url); define('ZENDESK_EMAIL', $zendesk_user->email); define('ZENDESK_PASSWORD', $zendesk_user->password); define('ZENDESK_TIMEZONE', (int) $zendesk_user->timezone); // create a ticket to zendesk $xml = '<ticket>' . '<subject>Phone Call from ' . format_phone($_REQUEST['Caller']) . ' on ' . gmdate('M d g:i a', gmmktime() + ZENDESK_TIMEZONE * 60 * 60) . '</subject>' . '<description>' . $_REQUEST['TranscriptionText'] . "\n" . 'Recording: ' . $_REQUEST['RecordingUrl'] . '</description>' . '</ticket>'; $new_ticket = zendesk_client('/tickets.xml', 'POST', $xml); $params = http_build_query($_REQUEST); $redirect_url = site_url('twiml/transcribe') . '?' . $params; header("Location: {$redirect_url}"); } else { $permissions = AppletInstance::getUserGroupPickerValue('permissions'); // get the prompt that the user configured $isUser = $permissions instanceof VBX_User ? TRUE : FALSE; if ($isUser) { $prompt = $permissions->voicemail; } else { $prompt = AppletInstance::getAudioSpeechPickerValue('prompt'); } $verb = AudioSpeechPickerWidget::getVerbForValue($prompt, new Say("Please leave a message.")); $response->append($verb); // add a <Record>, and use VBX's default transcription handle$response->addRecord(array('transcribe'=>'TRUE', 'transcribeCallback' => site_url('/twiml/transcribe') )); $action_url = base_url() . "twiml/applet/voice/{$flow_id}/{$instance_id}?status=save-call"; $transcribe_url = base_url() . "twiml/applet/voice/{$flow_id}/{$instance_id}?status=transcribe-call"; $response->addRecord(array('transcribe' => 'TRUE', 'action' => $action_url, 'transcribeCallback' => $transcribe_url)); } } $response->Respond(); // send response
/** * If the result of a no-answer is to take a voicemail then * we determine if its a user or group voicemail and then prompt for a record * * Also, if the result of no-answer is to redirect then that is handled here too. * An empty redirect value will cause a hangup. * * @return void */ protected function no_answer_object() { if ($this->no_answer_action === 'voicemail') { switch ($this->dial_whom_instance) { case 'VBX_User': $voicemail = $this->dial_whom_user_or_group->voicemail; break; case 'VBX_Group': $voicemail = $this->no_answer_group_voicemail; break; default: $voicemail = null; } if (!AudioSpeechPickerWidget::setVerbForValue($voicemail, $this->response)) { // fallback to default voicemail message $this->response->say(self::$default_voicemail_message, array('voice' => $this->voice, 'language' => $this->language)); } $record_params = array(); if ($this->transcribe) { $record_params['transcribeCallback'] = site_url('twiml/transcribe'); } $this->response->record($record_params); $this->state = 'recording'; } else { if ($this->no_answer_action === 'redirect') { if (empty($this->no_answer_redirect)) { $this->hangup(); } $this->response->redirect($this->no_answer_redirect); } else { if ($this->no_answer_action === 'hangup') { $this->hangup(); } else { throw new TwimlDialException("Unexpected no_answer_action"); } } } }
/** * If the result of a no-answer is to take a voicemail then * we determine if its a user or group voicemail and then prompt for a record * * Also, if the result of no-answer is to redirect then that is handled here too. * An empty redirect value will cause a hangup. * * @return void */ protected function no_answer_object() { if ($this->no_answer_action === 'voicemail') { switch ($this->dial_whom_instance) { case 'VBX_User': $voicemail = $this->dial_whom_user_or_group->voicemail; break; case 'VBX_Group': $voicemail = $this->no_answer_group_voicemail; break; default: $voicemail = null; } $this->response->append(AudioSpeechPickerWidget::getVerbForValue($voicemail, new Say(self::$default_voicemail_message))); $this->response->addRecord(array('transcribeCallback' => site_url('twiml/transcribe'))); $this->state = 'recording'; } else { if ($this->no_answer_action === 'redirect') { if (empty($this->no_answer_redirect)) { $this->hangup(); } $this->response->addRedirect($this->no_answer_redirect); } else { if ($this->no_answer_action === 'hangup') { $this->hangup(); } else { trigger_error("Unexpected no_answer_action"); } } } }
$CI =& get_instance(); $transcribe = (bool) $CI->vbx_settings->get('transcriptions', $CI->tenant->id); $response = new TwimlResponse(); // start a new Twiml response if (!empty($_REQUEST['RecordingUrl'])) { // add a voice message OpenVBX::addVoiceMessage(AppletInstance::getUserGroupPickerValue('permissions'), $CI->input->get_post('CallSid'), $CI->input->get_post('From'), $CI->input->get_post('To'), $CI->input->get_post('RecordingUrl'), $CI->input->get_post('RecordingDuration'), $transcribe == false); } else { $permissions = AppletInstance::getUserGroupPickerValue('permissions'); // get the prompt that the user configured $isUser = $permissions instanceof VBX_User ? true : false; if ($isUser) { $prompt = $permissions->voicemail; } else { $prompt = AppletInstance::getAudioSpeechPickerValue('prompt'); } if (!AudioSpeechPickerWidget::setVerbForValue($prompt, $response)) { // fallback to default voicemail message $response->say('Please leave a message. Press the pound key when you are finished.', array('voice' => $CI->vbx_settings->get('voice', $CI->tenant->id), 'language' => $CI->vbx_settings->get('voice_language', $CI->tenant->id))); } // add a <Record>, and use VBX's default transcription handler $record_params = array('transcribe' => 'false'); if ($transcribe) { $record_params['transcribe'] = 'true'; $record_params['transcribeCallback'] = site_url('/twiml/transcribe'); } $response->record($record_params); } $response->respond(); // send response
<?php $response = new Response(); $next = AppletInstance::getDropZoneUrl('next'); $prompt = AppletInstance::getAudioSpeechPickerValue('prompt'); $response->append(AudioSpeechPickerWidget::getVerbForValue($prompt, null)); if (!empty($next)) { $response->addRedirect($next); } $response->Respond();
$response->say('You selected an incorrect option.', array('voice' => $ci->vbx_settings->get('voice', $ci->tenant->id), 'language' => $ci->vbx_settings->get('voice_language', $ci->tenant->id))); $response->redirect(); } $response->respond(); exit; } } if (!empty($selected_item)) { $response->redirect($selected_item); $response->respond(); exit; } $gather = $response->gather(compact('numDigits')); // $verb = AudioSpeechPickerWidget::getVerbForValue($prompt, null); AudioSpeechPickerWidget::setVerbForValue($prompt, $gather); // $gather->append($verb); // Infinite loop if ($repeat_count == -1) { $response->redirect(); // Specified repeat count } else { for ($i = 1; $i < $repeat_count; $i++) { $gather->pause(array('length' => 5)); AudioSpeechPickerWidget::setVerbForValue($prompt, $gather); // $gather->append($verb); } } if (!empty($next)) { $response->redirect($next); } $response->respond();
<?php $response = new Response(); // start a new Twiml response if (!empty($_REQUEST['RecordingUrl'])) { // add a voice message OpenVBX::addVoiceMessage(AppletInstance::getUserGroupPickerValue('permissions'), $_REQUEST['CallSid'], $_REQUEST['From'], $_REQUEST['To'], $_REQUEST['RecordingUrl'], $_REQUEST['RecordingDuration']); } else { $permissions = AppletInstance::getUserGroupPickerValue('permissions'); // get the prompt that the user configured $isUser = $permissions instanceof VBX_User ? true : false; if ($isUser) { $prompt = $permissions->voicemail; } else { $prompt = AppletInstance::getAudioSpeechPickerValue('prompt'); } $verb = AudioSpeechPickerWidget::getVerbForValue($prompt, new Say("Please leave a message. Press the pound key when you are finished.")); $response->append($verb); // add a <Record>, and use VBX's default transcription handler $response->addRecord(array('transcribeCallback' => site_url('/twiml/transcribe'))); } $response->Respond(); // send response