public function __construct($settings = array()) { $this->response = new TwimlResponse(); $this->cookie_name = 'state-' . AppletInstance::getInstanceId(); $this->version = AppletInstance::getValue('version', null); $this->callerId = AppletInstance::getValue('callerId', null); if (empty($this->callerId) && !empty($_REQUEST['From'])) { $this->callerId = $_REQUEST['From']; } /* Get current instance */ $this->dial_whom_selector = AppletInstance::getValue('dial-whom-selector'); $this->dial_whom_user_or_group = AppletInstance::getUserGroupPickerValue('dial-whom-user-or-group'); $this->dial_whom_number = AppletInstance::getValue('dial-whom-number'); $this->no_answer_action = AppletInstance::getValue('no-answer-action', 'hangup'); $this->no_answer_group_voicemail = AppletInstance::getAudioSpeechPickerValue('no-answer-group-voicemail'); $this->no_answer_redirect = AppletInstance::getDropZoneUrl('no-answer-redirect'); $this->no_answer_redirect_number = AppletInstance::getDropZoneUrl('no-answer-redirect-number'); $this->dial_whom_instance = get_class($this->dial_whom_user_or_group); if (count($settings)) { foreach ($settings as $setting => $value) { if (isset($this->{$setting})) { $this->{$setting} = $value; } } } }
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(); }
public function __construct() { $this->response = new Response(); $this->cookie_name = 'state-' . AppletInstance::getInstanceId(); $this->version = AppletInstance::getValue('version', null); $this->callerId = AppletInstance::getValue('callerId', null); if (empty($this->callerId)) { $this->callerId = $_REQUEST['From']; } /* Get current instance */ $this->dial_whom_selector = AppletInstance::getValue('dial-whom-selector'); $this->dial_whom_user_or_group = AppletInstance::getUserGroupPickerValue('dial-whom-user-or-group'); $this->dial_whom_number = AppletInstance::getValue('dial-whom-number'); $this->no_answer_action = AppletInstance::getValue('no-answer-action', 'hangup'); $this->no_answer_group_voicemail = AppletInstance::getAudioSpeechPickerValue('no-answer-group-voicemail'); $this->no_answer_redirect = AppletInstance::getDropZoneUrl('no-answer-redirect'); $this->no_answer_redirect_number = AppletInstance::getDropZoneUrl('no-answer-redirect-number'); }
<?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();
define('DIAL_STATE_DIAL', 'dialStateDial'); define('DIAL_STATE_NO_ANSWER', 'dialStateNoAnswer'); define('DIAL_STATE_RECORDING', 'dialStateRecording'); define('DIAL_STATE_HANGUP', 'dialStateHangup'); $response = new Response(); // Default State $state = array(); $state[DIAL_ACTION] = DIAL_STATE_DIAL; $state[DIAL_NUMBER_INDEX] = 0; $version = AppletInstance::getValue('version', null); /* Get current instance */ $dial_whom_selector = AppletInstance::getValue('dial-whom-selector'); $dial_whom_user_or_group = AppletInstance::getUserGroupPickerValue('dial-whom-user-or-group'); $dial_whom_number = AppletInstance::getValue('dial-whom-number'); $no_answer_action = AppletInstance::getValue('no-answer-action', 'hangup'); $no_answer_group_voicemail = AppletInstance::getAudioSpeechPickerValue('no-answer-group-voicemail'); $no_answer_redirect = AppletInstance::getDropZoneUrl('no-answer-redirect'); $no_answer_redirect_number = AppletInstance::getDropZoneUrl('no-answer-redirect-number'); $numbers = array(); $voicemail = null; if ($dial_whom_selector === 'user-or-group') { $dial_whom_instance = null; if (is_object($dial_whom_user_or_group)) { $dial_whom_instance = get_class($dial_whom_user_or_group); } switch ($dial_whom_instance) { case 'VBX_User': foreach ($dial_whom_user_or_group->devices as $device) { if ($device->is_active == 1) { $numbers[] = $device->value; }
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
<?php $response = new Response(); /* Fetch all the data to operate the menu */ $digits = isset($_REQUEST['Digits']) ? $_REQUEST['Digits'] : false; $prompt = AppletInstance::getAudioSpeechPickerValue('prompt'); $invalid_option = AppletInstance::getAudioSpeechPickerValue('invalid-option'); $repeat_count = AppletInstance::getValue('repeat-count', 3); $next = AppletInstance::getDropZoneUrl('next'); $selected_item = false; /* Build Menu Items */ $choices = (array) AppletInstance::getDropZoneUrl('choices[]'); $keys = (array) AppletInstance::getDropZoneValue('keys[]'); $menu_items = AppletInstance::assocKeyValueCombine($keys, $choices); $numDigits = 1; foreach ($keys as $key) { if (strlen($key) > $numDigits) { $numDigits = strlen($key); } } if ($digits !== false) { if (!empty($menu_items[$digits])) { $selected_item = $menu_items[$digits]; } else { if ($invalid_option) { $verb = AudioSpeechPickerWidget::getVerbForValue($invalid_option, null); $response->append($verb); $response->addRedirect(); } else { $response->addSay('You selected an incorrect option.'); $response->addRedirect();