PHP code example of live-person-inc / live-engage-laravel

1. Go to this page and download the library: Download live-person-inc/live-engage-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

live-person-inc / live-engage-laravel example snippets


LivePersonInc\LiveEngageLaravel\ServiceProvider::class,

'LiveEngage' => LivePersonInc\LiveEngageLaravel\Facades\LiveEngageLaravel::class,

'liveperson' => [
    'default' => [
	    'key' => 'xxxxxxx',
	    'secret' => 'xxxxxxx',
	    'token' => 'xxxxxxx',
	    'token_secret' => 'xxxxxxx',
	    'account' => '123456',
    ]
],

'liveperson' => [
    'default' => [
	    'key' => 'xxxxxxx',
	    'secret' => 'xxxxxxx',
	    'token' => 'xxxxxxx',
	    'token_secret' => 'xxxxxxx',
	    'account' => '123456',
    ],
    'history' => [
	    'key' => 'xxxxxxx',
	    'secret' => 'xxxxxxx',
	    'token' => 'xxxxxxx',
	    'token_secret' => 'xxxxxxx',
	    'account' => '123456',
    ],
    'attributes' => [
	    'key' => 'xxxxxxx',
	    'secret' => 'xxxxxxx',
	    'token' => 'xxxxxxx',
	    'token_secret' => 'xxxxxxx',
	    'account' => '123456',
    ]
],

$history = LiveEngage::key('history')->engagementHistory(); //conversationHistory() for messaging

$history = LiveEngage::engagementHistory(); //conversationHistory() for messaging

use LiveEngage;
use Carbon\Carbon;

$start = new Carbon('2018-06-01 08:00:00');
$end = new Carbon('2018-06-03 17:00:00');

/**
 * engagementHistory function.
 * 
 * @access public
 * @param Carbon $start (default: null)
 * @param Carbon $end (default: null)
 * @param mixed $skills (default: [])
 */ 
$history = LiveEngage::engagementHistory($start, $end);

use LiveEngage;
use Carbon\Carbon;

$start = new Carbon('2018-06-01 08:00:00');
$end = new Carbon('2018-06-03 17:00:00');
$skills = [432,676];

$history = LiveEngage::engagementHistory($start, $end, $skills);

$history->next(); // one page

while ($next = $history->next()) { $history = history->merge($next) } // get all remaining data

$engagement = $history->find('3498290084'); // This is a collection, so random(), first(), last() all work as well

foreach ($engagement->transcript as $message) {  // For messaging conversations, use messageRecords instead of transcript
	echo $message . "\n"; // calling the message object as a string returns its text value
}

echo $message->time->format('Y-m-d'); //The all time properties are Carbon date objects.

$conversation = LiveEngage::conversationHistory()->first();

foreach ($conversation->transfers as $transfer) {
	echo $transfer->targetSkillName . "\n";
}

$availableAgents = LiveEngage::getAgentStatus(17); //Skill ID 17

$online = $availableAgents->state('online');
$away = $availableAgents->state('away');