예제 #1
0
            } 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");
                        }
                    }
                }
            }
            break;
        case DIAL_STATE_RECORDING:
            if (isset($_REQUEST['testing'])) {
                break;
            }
            OpenVBX::addVoiceMessage($dial_whom_user_or_group, $_REQUEST['CallGuid'], $_REQUEST['Caller'], $_REQUEST['Called'], $_REQUEST['RecordingUrl'], $_REQUEST['Duration']);
            break;
    }
}
setcookie(DIAL_COOKIE, json_encode($state), time() + 5 * 60);
$response->Respond();
예제 #2
0
 /**
  * Handle callback after someone leaves a message
  *
  * @return void
  */
 public function add_voice_message()
 {
     OpenVBX::addVoiceMessage($this->dial_whom_user_or_group, $_REQUEST['CallSid'], $_REQUEST['From'], $_REQUEST['To'], $_REQUEST['RecordingUrl'], $_REQUEST['RecordingDuration']);
     $this->response->say('Your message has been recorded. Goodbye.');
     $this->hangup();
 }
예제 #3
0
 /**
  * Handle callback after someone leaves a message
  *
  * @return void
  */
 public function add_voice_message()
 {
     OpenVBX::addVoiceMessage($this->dial_whom_user_or_group, $_REQUEST['CallSid'], $_REQUEST['From'], $_REQUEST['To'], $_REQUEST['RecordingUrl'], $_REQUEST['RecordingDuration']);
 }
예제 #4
0
    if (curl_errno($ch)) {
        error_log('CURL failed due to ' . curl_error());
        return FALSE;
    } else {
        if ($ch_info['http_code'] >= 200 && $ch_info['http_code'] < 300) {
            return TRUE;
        }
    }
    return FALSE;
}
// }}}
$response = new Response();
// start a new Twiml response
if ($status == 'save-call' && @$_REQUEST['RecordingUrl']) {
    // add a voice message
    OpenVBX::addVoiceMessage(AppletInstance::getUserGroupPickerValue('permissions'), $_REQUEST['CallSid'], $_REQUEST['Caller'], $_REQUEST['Called'], $_REQUEST['RecordingUrl'], $_REQUEST['Duration']);
} else {
    if ($status == 'transcribe-call') {
        $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 {
예제 #5
0
<?php

$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();