Plugin API » Data

Messages

To add voice, sms, or your own types of voicemail into the OpenVBX Messages system.

OpenVBX::addVoiceMessage( $owner, $guid, $caller, $called, $recording_url, $duration )

Arguments

Name Type Description
$owner object Object of Owner, can be Group or User
$guid string Unique call SID, generated by Call Api provider
$caller phone number Number of caller
$called phone number Number being called
$recording_url string URL of recording
$duration integer Length of recording in seconds

Returns

  • boolean — true on success

Usage

OpenVBX::addVoiceMessage(
                    $owner, 
                    $guid, 
                    $caller, 
                    $called, 
                    $recording_url, 
                    $duration
                );

Examples

$owner = VBX_User::get(array('id' => 1));
$guid = $_REQUEST['CallSid'];
$caller = $_REQUEST['Caller'];
$called = $_REQUEST['Called'];
$recording_url = $_REQUEST['RecordingUrl'];
$duration = $_REQUEST['Duration'];
OpenVBX::addVoiceMessage(
                    $owner, 
                    $guid, 
                    $caller, 
                    $called, 
                    $recording_url, 
                    $duration
                );

OpenVBX::addSMSMessage( $owner, $guid, $to, $from, $body )

Arguments

Name Type Description
$owner object Object of Owner, can be Group or User
$guid string Unique call SID, generated by Call Api provider
$to phone number Number of message recipient
$from phone number Number of message sender
$body string Body of SMS message

Returns

  • boolean — true on success

Usage

OpenVBX::addSMSMessage( $owner, $guid, $to, $from, $body );

Examples

$owner = VBX_User::get(array('id' => 1));
$guid = $_REQUEST['CallSid'];
$from = $_REQUEST['From'];
$to = $_REQUEST['To'];
$body = $_REQUEST['Body'];
OpenVBX::addSMSMessage( $owner, $guid, $to, $from, $body );

OpenVBX::addMessage( $owner, $guid, $caller, $called, $recording_url, $duration, $type = VBX_Message::TYPE_VOICE, $text = null, $notify = false )

Arguments

Name Type Description
$owner object Object of Owner, can be Group or User
$guid string Unique call SID, generated by Call Api provider
$caller phone number Number of caller
$called phone number Number being called
$recording_url string URL of recording
$duration integer Length of recording in seconds
$type string, CONSTANT String or VBX_Message Type Constant. VBX_Message::TYPE_VOICE, VBX_Message::TYPE_SMS
$notify boolean Boolean of whether to email the owner when message is stored

Returns

  • boolean — true on success

Usage

OpenVBX::addMessage(
                $owner, 
                $guid, 
                $caller, 
                $called, 
                $recording_url, 
                $duration,
                VBX_Message::TYPE_SMS, "my sms message", 
                true
            );

Examples

$owner = VBX_User::get(array('id' => 1));
$guid = $_REQUEST['CallSid'];
$caller = $_REQUEST['Caller'];
$called = $_REQUEST['Called'];
$body = $_REQUEST['Body'];
OpenVBX::addVoiceMessage( 
                    $owner, 
                    $guid, 
                    $caller, 
                    $called, 
                    null, 
                    null,
                    VBX_Message::TYPE_VOICE, 
                    $body, 
                    true
                );