How to use Chat Rest API module?

Last modification: 2017-02-20 13:55:47

Chat Rest API modules allows to do the following things

  • Check global status is anyone online
  • Check status for custom users
  • Check status for departments

Where this module can be used?

this module can be used for custom status widget generation. Integration LHC with other applicatios. Writing custom UI from scratch

In what format module exports data?

Chat exports data in JSON format. Module also supports PJSON

How to check is anyone online? -  for general check - for PJSON, callback value can be any

How to check is user online? - last parameters is user id - last parameters is user id

How to check is department online? - last parameters is department id. This function checks for online department explicit. That means if for user is assigned all departments department will be offline. - last parameters is department id

How to log online visitor?

This can be used inside any desktop application to log visitor activity in application itself.

$response = $LHCRestAPI->execute('chatcheckoperatormessage', array(
    'ip' => ''
    'dt' => 'APPLICATIN_NAME - Some Application Specific Window',
    'ua' => '', // User Agent
 ), array(
    'vid' => '',                  // It's new visitor it still has not vid assigned
    'count_page' => 1,  // Log it as real page view, not just message check from operator
    'tz' => 0,                    // Time Zone offset from GMT
    'priority' => 0,         // Chat priority
    'operator' => 0,       // Operator
    'theme' => 0,            // Theme
    'survey' => 0,           // Survey (optional)
    'department' => 5,  // Department (optional)
    'uactiv' => 1              // Is user considered active or not
), 'POST');

If response does not caontains any errors you can vid by

if ($response->error == false && isset($response->result->vid)) {
    $response2 = $LHCRestAPI->execute('chatcheckoperatormessage', array(
        'ip' => '',
        'dt' => 'APPLICATIN_NAME - About window',
        'ua' => '', // User Agent
    ), array(
        'vid' => $response->result->vid,
        'count_page' => 1,  
        'tz' => 0,          
        'priority' => 0,    
        'operator' => 0,    
        'survey' => 0,      
        'uactiv' => 1       
    ), 'POST',true,'');

 // If there is unread message we can read message from operator

    if ($response->error == false && $response->result->action == 'read_message') {
        $urlAppend = $response->result->args->url_append;
        echo "Reading message from operator\n";
        // @todo add message read from operator
    } elseif ($response->error == false && $response->result->action == 'continue') {
        // Just repeat request

    echo "Second page view\n";
/* } else {
    echo "Some error\n";    
} */

Possible action values

  • disable_check - there should not be any more requests to "chatcheckoperatormessage"
  • continue - just continue sending these request untill user makes some actions or just trigger get's activacted
  • read_message - there is pending message from operator or proactive trigger


How to list chats, departments, messages, get chat information?

Just refer to this example


Support project

Developing application takes a lot of time. You can support application by donating. There is no company behind this application and it takes away my free time. Every donation matters and does not matter how small it is!

Paypal, one time donation
Monthly donation

comments powered by Disqus