Integre o Livezilla com seu Software via API

API LiveZilla Widget

A API LiveZilla Widget permite que você aplique configurações ou altere aspectos visuais no local por meio de chamadas de Javascript. Certifique-se de que o código do botão de bate-papo do LiveZilla (versão 7.1.0.1 e superior) esteja integrado na página onde você deseja acessar a API.

Dados privados

Se você tiver cookies configurados como "Opt-In", esta chamada ativa o uso de cookies.

Cookie Opt-In
LiveZilla.OptInCookies();

Se você tiver cookies configurados como "Opt-In", esta chamada ativa o uso de cookies.

Cookie Opt-In
LiveZilla.OptInCookies();

Se você tiver cookies configurados como "Opt-Out", esta chamada remove todos os cookies e garante que nenhum outro cookie será definido.

Cookie Opt-Out
LiveZilla.OptOutCookies();

O monitoramento do visitante será desativado para o visitante para sempre.

Monitoramento de visitante / desativação de rastreamento
LiveZilla.OptOutTracking();

Data Pass-Thru

Use esta função para alterar detalhes do visitante, como nome ou e-mail, passando um objeto de dados. Observe esta entrada de FAQ .

Alterar / definir detalhes do visitante
LiveZilla.SetData({overwrite:true,111:'Tom',112:'[email protected]'});

Controles de interface de usuário de widget
Certifique-se de ativar o "Modo API" ao criar seu código de botão de bate-papo no Gerador de links LiveZilla

Mostrar widget
OverlayChatWidgetV2.Show();

Ocultar widget
OverlayChatWidgetV2.Hide();

Alternar serviço de widget
OverlayChatWidgetV2.SetMode(chat|ticket|phone|knowledgebase);

Eventos

Executar Evento
LiveZilla.ExecuteEvent(eventid);

LiveZilla Chat Bot API

Chat Bot API Information and Usage


This is the documentation for the LiveZilla Chat Bot API included from 7.0.5.0. Please read the contents of this page carefully.

While the LiveZilla Chat Bot in its standard setting is able to browse the Knowledge Base, you can use the Chat Bot API in order to perform more complex processes. The logic of the Chat Bot API needs to be placed inside a separate ChatBot script (e.g. PHP).

Each Chat Bot can have its own script which needs to be saved as an absolute URL (see Bot Account in User Management).

The Chat Bot API is supposed to exchange data between the LiveZilla server and the Chat Bot script as well as visualizing it on the user side. Each inquiry consists of two objects (REQUEST and RESPONSE) which are exchanged in JSON format via POST. The user input (REQUEST) is sent to the Chat Bot script which processes it and immediately sends the RESPONSE.

  All errors will be logged in _log/error_php.log.

Request Object (Visitor)
Request object is represented as JSON objects having the following keys:

 

JSON KeyTypeCommentExample
RequestNumberintRequests serial number starting with 00
ResponseTostringLast Response IDR7546584783
ValuestringVisitors inputHi, this is a test
BotIdstringID of Botb23d62db4063344
BotNamestringName of BotExample Bot
VisitorNamestringName of VisitorJohn
VisitorIdstringID of Visitorv23d62db4063344
GroupIdstringID of Groupsupport
HumanAvailableboolHuman operator is availabletrue
LanguagestringVisitor Language (ISO 639-1 Code)FR
Operatorsarray(operator)Operator List[operator1, operator2]
TagobjectTag from last Response{prop:value,…}
KBMatchCountintNumber of knowledge base entries matching request3

When visitors end the chat, an Exit Message with the value “[__[EXIT]__]” will be sent to your script automatically.

 

Operator Object
Operator object is represented as JSON objects having the following keys:

 

JSON KeyTypeCommentExample
IdstringOperator IDjohn_doe
FullnamestringName of operatorJohn Doe
Statusstring0 | 1 | 2 | 3 (Online, Busy, Offline, Away)0
Groupsarray(string)List of groups this operator is a member of[“support”, “tech”]
Response Object (Bot)
Response object is represented as JSON objects having the following keys:

 

JSON KeyTypeRequiredCommentExample
IdstringYesAlphanumeric ID, max 32 charsR7546584783
ValuestringNoGeneral response text (HTML)Hi, this is my answer
Selectarray(Button)NoButton list[button1, button2]
SearchKBboolNoSearch knowledge base and add resultsfalse
BlockboolNoBlock input fieldfalse
Actionchat | messageNoStart chat with human or leave a messagechat
OperatorstringNoAction target operator (ID)john_doe
GroupstringNoAction target group (ID)support
Dataarray(int,string)NoStore visitor information[111=>”John”, 112=>”[email protected]”]
TagobjectNoTag to be returned with next Request{prop:value,…}
Button Object
Button object is represented as JSON objects having the following keys:

 

JSON KeyTypeRequiredCommentExample
TitlestringYesButton title (HTML)Button 1
ReturnstringNoThe value sent back as response after click 
URLstringNoURL to be opened on clickhttp://…
ScriptstringNoJavscript code to be executed on clickalert(123);
Actionchat | messageNoStart chat with human or leave a messagechat
OperatorstringNoAction target operator (ID)john_doe
GroupstringNoAction target group (ID)support
ChatBot-Script QuickStart Example

 

<?php
$requestObject = json_decode($_POST["livezilla_user_api_request"]);

$responseObject = array();
$responseObject["Value"] = "";
$responseObject["Id"] = rand(1111111,9999999);
$responseObject["SearchKB"] = false;

if($requestObject->RequestNumber==0 || $requestObject->Value=='list')
{
    $responseObject["Select"] = array();
    $responseObject["Select"][] = array("title"=>"Enter something","return"=>"something");
    $responseObject["Select"][] = array("title"=>"Link (go to website)","url"=>"http://www.livezilla.net","return"=>"");
    $responseObject["Select"][] = array("title"=>"Run some Javascript (JS)","script"=>"alert(123);","return"=>"");
    $responseObject["Select"][] = array("title"=>"Start a Chat","action"=>"chat","operator"=>"administrator","group"=>"support");
    $responseObject["Select"][] = array("title"=>"Leave a Message","action"=>"message","group"=>"support");
                    $responseObject["Value"] = "Thanks for testing me. Here's a list of options, please click something or type 'list' to reset.";
}

if(!empty($responseObject["Value"]))
    echo json_encode($responseObject);
?>
        
ChatBot-Script Program-O Bot

 

<?php
$requestobj = json_decode($_POST["livezilla_user_api_request"]);
$responseNode = array();
$responseNode["ResponseTo"] = "";
$responseNode["Id"] = rand(1111111,9999999);
$responseNode["SearchKB"] = false;

$url = "http://api.program-o.com/v2/chatbot/?bot_id=6&say=".rawurlencode($requestobj->Value)."&convo_id=".$requestobj->VisitorId."&format=json";
$sdata = json_decode(file_get_contents($url));
$responseNode["Value"] = $sdata->botsay;

if(!empty($responseNode["Value"]))
	echo json_encode($responseNode);
?>
        
ChatBot-Script Pizza Bot

 

<?php
$requestobj = json_decode($_POST["livezilla_user_api_request"]);

$responseNode = array();
$responseNode["Value"] = "";
$responseNode["ResponseTo"] = "";
$responseNode["SearchKB"] = false;

if($requestobj->Value != "[__[EXIT]__]")
{
    // first user interaction
    if($requestobj->ResponseTo == "")
    {
        // store initial question
        $responseNode["Data"] = array();
        $responseNode["Data"]["114"] = $requestobj->Value;

        $responseNode["Id"] = "action:request_name";
        $responseNode["Value"] = "Ok. What's your name please?";
    }

    // user defines name
    if($requestobj->ResponseTo == "action:request_name")
    {
        $responseNode["Id"] = "action:request_pizza_type";
        $responseNode["Value"] = "Great, nice to meet you <b>" . $requestobj->Value . "</b>.";
        $responseNode["Value"] .= "What size do you like your Pizza?<br><br>";

        // store name
        $responseNode["Data"]["111"] = $requestobj->Value;
        $responseNode["Data"] = array();

        $responseNode["Select"] = array();
        $responseNode["Select"][] = array("title"=>"Medium - 10\" / 25 cm.","return"=>"Medium");
        $responseNode["Select"][] = array("title"=>"Italian - 12\" / 30 cm.","return"=>"Italian");
        $responseNode["Select"][] = array("title"=>"Large - 14\" / 35 cm.","return"=>"Large");

        // block input field
        $responseNode["Block"] = true;
    }

    // user defines pizza style
    if($requestobj->ResponseTo == "action:request_pizza_type")
    {
        $responseNode["Id"] = "action:request_customer_number";
        $responseNode["Value"] = "Your Pizza will be " . $requestobj->Value . " style. All saved!";
        $responseNode["Value"] .= "Your customer number would be helpful, too. Do you have one?<br><br>";

        // store pizza type (represents custom combobox field 0)
        $responseNode["Data"] = array();
        $responseNode["Data"]["0"] = $requestobj->Value;

        $responseNode["Select"] = array();
        $responseNode["Select"][] = array("title"=>"Yes","return"=>"Yes");
        $responseNode["Select"][] = array("title"=>"No","return"=>"No");

        // block input field
        $responseNode["Block"] = true;
    }

    if($requestobj->ResponseTo == "action:request_customer_number")
    {
        // and so on ...
        $responseNode["Value"] = "This demo ends here ...";
        $responseNode["Block"] = false;
    }
}
else
{
    // say good bye
    $responseNode["Id"] = "action:end_chat";
    $responseNode["Value"] = "Take care, bye!";
}
echo json_encode($responseNode);
?>

API Chat Versão 2

Endpoints e utilização da API relacionada ao Chat Livezilla

General API Information and Usage


This is the documentation for the LiveZilla API V2 included from 5.2.5.x. Please read the contents of this page carefully.

Unlike other (RESTful) APIs, the LiveZilla API is solely based on POST and JSON. We do not make use of GET, PUT, DELETE or custom HEADER calls and statements to ensure highest availability – even on shared hosting platforms with limited configuration options.

LiveZilla V2 API calls must be HTTP POST requests targeting:


http(s)://{yourdomain}/livezilla/api/v2/api.php



Authentication and Security


All API calls must include the POST parameters p_user and p_pass to authenticate against the LiveZilla server.

Any LiveZilla operator login information can be used for API call. Permission for API calls must be granted under:

User Management -> Roles -> Role -> API

For security reasons it’s recommended practice to:

  • Use HTTPS for all connections to your server
  • Configure your LiveZilla to require HTTPS (Server Configuration -> Security -> Require HTTPS)
  • Configure an IP Range for your Operator (API) accounts (User Management -> Operators -> Operator -> Security)





Required Authentication Parameters


These POST parameters must be passed with every API Call.

NamePOST KeyTypeRequiredCommentExample
Userp_userstringYesAPI Authentication Useradministrator
Passp_passstringYesAPI Authentication Password (md5 encoded)md5(‘password’)





Optional Parameters


These optional POST parameters can be passed with every API Call.

NamePOST KeyTypeRequiredCommentExample
JSON_Prettyp_json_prettyintNoActivates PHP JSON Pretty Print output1
Operator Object Format
Operator is represented as JSON objects having the following keys:

 

JSON KeyTypeRequiredRead onlyCommentExample
UserIdstringYesNoThe alphanumeric login ID of the operators.john_doe
FullnamestringYesNoOperators full name.John Doe
EmailstringYesNoOperators email.[email protected]
LanguagestringYesNoISO two letter language code.EN
WebspaceintYesNoWebspace in MB operator is allowed to use for file uploads (0=deactivated).100
PasswordstringYesNoOperators password (MD5 encoded).md5(‘johns_password’)
GroupsarrayYesNoList of group IDs representing the groups the operators is a member of.groupid1,groupid2
PermissionSetstringYesNo

String representing the operators permission set.

[0] = TicketPermission
[1] = RatingPermission
[2] = ChatExternalArchivePermission
[3] = ResourcePermission
[4] = EventPermission
[5] = ReportPermission
[6] = MonitoringPermission
[7] = JoinChats
[8] = JoinChatsInvisibly
[9] = TakeChats
[10] = SetChatPriority
[11] = SetChatGroup
[12] = SetChatOperator
[13] = ChatPermission
[14] = SendInvitations
[15] = ClearText
[16] = ForwardChats
[17] = JoinChatsWhenInvited
[18] = DynamicGroupPermission
[19] = CreateFilters
[20] = BotEditPermission
[21] = ChangePicture
[22] = TicketReviewEmails
[23] = TicketCreate
[24] = TicketChangeSignature
[25] = TicketDeleteEmails
[26] = TicketChangeStatus
[27] = TicketChangeStatusOpen
[28] = TicketChangeStatusInProgress
[29] = TicketChangeStatusClosed
[30] = TicketAssignOperator
[31] = TicketAssignGroup
[32] = TicketOvertake
[33] = TicketProcessOpen
[34] = TicketDeleteGlobal
[35] = ProfilePermission
[36] = ChatInternalArchivePermission
[37] = TicketChangeStatusDeleted
[38] = StartChats
[39] = CancelInvitations
[40] = CancelInvitationsOfOthers
[41] = TicketEdit
[42] = CanAutoAcceptChats
[43] = MustAutoAcceptChats
[44] = CanRejectChats
[45] = MobileAccess
[46] = API Access
[47] = KB Entries Read
[48] = KB Entries Write
[49] = Personal Chat Link
[50] = Delete Feedbacks
[51] = View Logs

Example: 2121202101000210111101111111111111011111011011022101

DescriptionstringNoNoDescription TextNice guy
LevelintNoNoDefines if operator is server administrator.1
StatusintNoYesOperator’s current online status (0=Online,1=Busy,2=Offline,3=Away).0
PictureFilestringNoYesOperator’s Image File, add to full URL.picture.php?intid…
ChatFilestringNoYesFile to initiate chat with Operator, add to full URL.chat.php?intid…
IsBotbooleanNoYesIs bot (or human).1
ExternalChatsarrayNoYesList of active (external) chat objects. (LiveZilla 5.4.0.1)chat1,chat2
ExternalChatCountintNoYesCount of active (external) chats. (LiveZilla 5.4.0.1)1
Operator Functions

 

List Operators
Function
As of version 5.2.5.0
POST /api/v2/api.php p_operators_list=1

Filters

 

NamePOST KeyTypeRequiredCommentExample
UserIdp_useridstringNoResponse will be the Operator matching this login Id.john_doe
Statusp_statusintNoReturns all operators having this status.1
Groupp_groupstringNoReturns all operators that are member of this group.groupid1
Full Chatsp_full_chatsboolNoReturn full list of external chat objects (LiveZilla 5.4.0.1).1

CURL Example

 

curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_operators_list=1 -X POST

 

Response

 

200 Ok: {
    "Operators": [
        {
            "Operator": {
                "Level": "1",
                "Webspace": 100,
                "Password": "a8c054e6b5e3edf349c1dac58157d1cd",
                "Description": "Nice guy",
                "PermissionSet": "2121202101000210111101111111111111011111011011022101",
                "Groups": [
                    "groupid1",
                    "groupid2"
                ],
                "UserId": "john_doe",
                "Language": "EN",
                "Fullname": "John Doe",
                "Email": "[email protected]"
            }
        },
        {
            "Operator": {
                "Level": "1",
                "Webspace": 100,
                "Password": "a8c054e6b5e3edf349c1dac58157d1cd",
                "Description": "Nice guy",
                "PermissionSet": "2121202101000210111101111111111111011111011011022101",
                "Groups": [
                    "groupid1",
                    "groupid2"
                ],
                "UserId": "john_doe",
                "Language": "EN",
                "Fullname": "John Doe",
                "Email": "[email protected]"
            }
        }
    ]
}

 

Error Codes

 

403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
Example: PHP code to list all online operators with chat link and image

 


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_operators_list"]=1;
            $postd["p_json_pretty"]=1;

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            echo "<hr>";
            curl_close($ch);

            $response = json_decode($server_output);

            if(count($response)==0)
                exit("No operators found");

            foreach($response->Operators as $obj)
            {
                if($obj->Operator->Status < 2 && !$obj->Operator->IsBot)
                {
                    echo "<img src=\"" . $livezillaURL . $obj->Operator->PictureFile . "\"> ";
                    echo $obj->Operator->Fullname . " is online ";
                    echo "<a href=\"" . $livezillaURL . $obj->Operator->ChatFile . "\" >Chat</a><br>";
                }
            }
    ?>

 

Create Operator
Function
As of version 5.2.5.0
POST /api/v2/api.php p_operator_create=1

CURL Example

 

curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_operator_create=1
-d p_data={ "Operator": { "Level": "1", "Webspace": 100, "Password": "a8c054e6b5e3edf349c1dac58157d1cd", "Description": "Nice guy", "PermissionSet": "2121202101000210111101111111111111011111011011022101", "Groups": [ "groupid1", "groupid2" ], "UserId": "john_doe", "Language": "EN", "Fullname": "John Doe", "Email": "[email protected]" } } -X POST

 

Response

 

200 Ok: {
    "Operator": {
        "Level": "1",
        "Webspace": 100,
        "Password": "a8c054e6b5e3edf349c1dac58157d1cd",
        "Description": "Nice guy",
        "PermissionSet": "2121202101000210111101111111111111011111011011022101",
        "Groups": [
            "groupid1",
            "groupid2"
        ],
        "UserId": "john_doe",
        "Language": "EN",
        "Fullname": "John Doe",
        "Email": "[email protected]"
    }
}

 

Error Codes

 

403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
Example: PHP code to create an operator account

 


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_operator_create"]=1;
            $postd["p_json_pretty"]=1;

            class Operator
            {
                public $UserId = 'john_doe';
                public $Firstname = 'John';
                public $Lastname = 'Doe';
                public $Email = '[email protected]';
                public $Language = 'EN';
                public $Webspace = '100';
                public $Password = "";
				public $Roles = "f7d450ede1fe1d035689c967f0836dfd";
				public $Skills = "purchasing";
				public $Location = "usa";
                public $Groups = array("support","sales");
            }

            $newOperator = new Operator();
            $newOperator->Password = md5("johnspassword");

            $postd["p_data"]= json_encode(array("Operator"=>$newOperator));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            curl_close($ch);
    ?>

 

Delete Operator
Function
As of version 5.2.5.0
POST /api/v2/api.php p_operator_delete=1

CURL Example

 

curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_operator_delete=1
-d p_userid=john_doe
-d p_data={ "Operator": { "UserId": "john_doe" } } -X POST

 

Response

 

200 Ok: {
    "Operator": {
        "Level": "1",
        "Webspace": 100,
        "Password": "a8c054e6b5e3edf349c1dac58157d1cd",
        "Description": "Nice guy",
        "PermissionSet": "2121202101000210111101111111111111011111011011022101",
        "Groups": [
            "groupid1",
            "groupid2"
        ],
        "UserId": "john_doe",
        "Language": "EN",
        "Fullname": "John Doe",
        "Email": "[email protected]"
    }
}

 

Error Codes

 

403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
Example: PHP code to delete an operator account

 


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_operator_delete"]=1;
            $postd["p_json_pretty"]=1;

            class Operator
            {
                public $UserId = 'john_doe';
            }

            $deleteOperator = new Operator();
            $postd["p_data"]= json_encode(array("Operator"=>$deleteOperator));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            curl_close($ch);
    ?>
ChatTranscript Object Format
ChatTranscript is represented as JSON objects having the following keys:

JSON KeyTypeRequiredRead onlyCommentExample
ChatIdstringYesYesThe chat ID11123
TimeStartintNoYesUNIX Timestamp of chat’s start time1395332157
TimeEndintNoYesUNIX Timestamp of chat’s end time1395332206
LanguagestringNoYesVisitor’s langauge (ISO two letter)EN
OperatorIdstringNoYesOperator’s User Idjohn_doe
VisitorIdstringNoYesVisitor’s Idbd1e10d650
GroupstringNoYesGroup Idgroupid1
HTMLstringNoYesHTML Chat Transcript<table width=”97%” border=”0″….
PlainTextstringNoYesPlain Text Chat Transcript| 20.03.2014 17:15:59 | Stefa…
FullnamestringNoYesVisitor’s nameJohanna Doe
EmailstringNoYesVisitor’s email[email protected]
CompanystringNoYesVisitor’s companyJdscompany Ltd.
QuestionstringNoYesVisitor’s questionCan you help me?
CountrystringNoYesVisitor’s countryUS
PhonestringNoYesVisitor’s phone #004988373728
HoststringNoYesVisitor’s host[email protected]
IPstringNoYesVisitor’s IP192.168.1.222
Customsarray<int,array<str, str>>NoYes
Custom input field values

array<index,array<input_name, input_value>>
Read more



ChatTranscript Functions



List Chat Transcripts
Function
As of version 5.2.5.0


POST /api/v2/api.php p_chats_list=1


Filters


NamePOST KeyTypeRequiredCommentExample
ChatIdp_chatidstringNoReturn the chat matching this chat Id.11123
Groupp_groupstringNoReturn all chats of this group.groupid1
Operatorp_operatorstringNoReturn all chats of this operator.john_doe
Start Afterp_start_afterstringNoReturn all chats with start time later than
YYYY-MM-DD HH:MM:SS
2014-01-01 23:59:59
Start Beforep_start_beforestringNoReturn all chats with start time earlier than
YYYY-MM-DD HH:MM:SS
2014-01-03 00:00:00
Outputp_outputstringNoHTML | PlaintextPlaintext
Limitp_limitintNoMaximum number of chats to return.100


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_chats_list=1
-d p_limit=10 -X POST

Response


200 Ok: {
    "Chats": [
        {
            "Chat": {
                "ChatId": "11123",
                "TimeStart": "1395332157",
                "TimeEnd": "1395332206",
                "Language": "EN",
                "OperatorId": "john_doe",
                "Group": "groupid1",
                "PlainText": "| 20.03.2014 17:15:59 | Stefa...",
                "HTML": "<table width="97%" border="0"....",
                "Fullname": "Johanna Doe",
                "Email": "[email protected]",
                "Company": "Jdscompany Ltd.",
                "Phone": "004988373728",
                "IP": "192.168.1.222",
                "Question": "Can you help me?",
                "Host": "[email protected]",
                "Country": "US",
                "Customs": ""
            }
        }
    ]
}

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


Example: PHP code to list all yesterday’s chat transcripts


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_chats_list"]=1;
            $postd["p_json_pretty"]=1;

            // filter parameters to include yesterday's tickets (100 maximum)
            $yesterdayBegin = strtotime("yesterday");
            $yesterdayEnd = strtotime("today");

            $postd["p_start_after"]=$yesterdayBegin;
            $postd["p_start_before"]=$yesterdayEnd;
            $postd["p_limit"]=100;
            $postd["p_output"]="Plaintext";

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
            exit(curl_error($ch));

            echo $server_output;
            echo "<hr>";
            curl_close($ch);

            $response = json_decode($server_output);

            if(count($response)==0)
            exit("No chats found");

            foreach($response->Chats as $obj)
            {
            echo "New chat: " . $obj->Chat->ChatId;
            echo "<br>";
            // further processing ...
            }
    ?>
Ticket Object Format
Ticket is represented as JSON objects having the following keys:

JSON KeyTypeRequiredRead onlyCommentExample
IdintNoYesThe serial ticket ID11123
GroupstringYesNoGroup Idgroupid1
ChannelintNoNo
Channel

[0] = Web
[1] = Email
[2] = Phone
[3] = Misc
[4] = Chat
[5] = Rating
Read more
SubChannelstringNoNoSub-Channel NameSub Channel Name
LanguagestringNoNoTicket’s Langauge (ISO two letter)EN
LastUpdatedintNoYesLast updated time (UNIX Timestamp)1395332206
WaitBeginintNoYesWait begin time (UNIX Timestamp)1395332157
Messagesarray<TicketMessage>NoYesTicket Messages 
EditorTicketEditorNoYesTicket Editor (Operator) 



Ticket Functions



List Tickets
Function
As of version 5.2.5.0


POST /api/v2/api.php p_tickets_list=1


Filters


NamePOST KeyTypeRequiredCommentExample
Idp_idstringNoReturn the ticket matching this Id.11123
Groupp_groupstringNoReturn all tickets of this group.groupid1
Operatorp_operatorstringNoReturn all tickets of this operator.john_doe
Created Afterp_created_afterstringNoReturn all tickets created later than
YYYY-MM-DD HH:MM:SS
2014-01-01 23:59:59
Created Beforep_created_beforestringNoReturn all tickets created earlier than
YYYY-MM-DD HH:MM:SS
2014-01-03 00:00:00
Limitp_limitintNoMaximum number of tickets to return.100
Statusp_statusstringNoReturn all tickets with specific status. Comma-separated list of statuses

[0] = Open
[1] = In Progress
[2] = Closed
[3] = Deleted
[4] = Pending
0,2,3


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_tickets_list=1
-d p_limit=10 -X POST

Response


200 Ok: {
    "Tickets": [
        {
            "Ticket": {
                "Messages": "",
                "Group": "groupid1",
                "Channel": "0",
                "SubChannel": "Sub Channel Name",
                "Language": "EN",
                "LastUpdated": "1395332206",
                "WaitBegin": "1395332157",
                "Editor": "",
                "Id": "11123"
            }
        }
    ]
}

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


Example: PHP code to list all yesterday’s tickets



    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_tickets_list"]=1;
            $postd["p_json_pretty"]=1;

            // filter parameters to include yesterday's tickets (100 maximum)
            $yesterdayBegin = strtotime("yesterday");
            $yesterdayEnd = strtotime("today");

            $postd["p_created_after"]=$yesterdayBegin;
            $postd["p_created_before"]=$yesterdayEnd;
            $postd["p_limit"]=100;

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            echo "<hr>";
            curl_close($ch);

            $response = json_decode($server_output);

            if(count($response->Tickets) == 0)
            exit("No tickets found");

            foreach($response->Tickets as $obj)
            {
                echo "New ticket: " . $obj->Ticket->Id;
                echo "<br>";
                // further processing ...
            }
    ?>
        




Create Ticket
Function
As of version 5.2.5.0


POST /api/v2/api.php p_ticket_create=1


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_ticket_create=1
-d p_data={ "Ticket": { "Group": "groupid1", "Channel": "0", "SubChannel": "Sub Channel Name", "Language": "EN" } } -X POST

Response


200 Ok: {
    "Ticket": {
        "Messages": "",
        "Group": "groupid1",
        "Channel": "0",
        "SubChannel": "Sub Channel Name",
        "Language": "EN",
        "LastUpdated": "1395332206",
        "WaitBegin": "1395332157",
        "Editor": "",
        "Id": "11123"
    }
}

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


Example: PHP code to create a ticket


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_ticket_create"]=1;
            $postd["p_json_pretty"]=1;

            class Ticket
            {
                public $Group = "support";
                public $CreationType = 0;
                public $Language = "en";
                public $Messages = array();
            }

            $newTicket = new Ticket();
            $postd["p_data"]= json_encode(array("Ticket"=>$newTicket));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
            exit(curl_error($ch));

            // Please don't miss to add a message to your ticket.
            // Tickets with no messages will not be displayed in the operator client software.

            echo $server_output;
            curl_close($ch);
    ?>
TicketMessage Object Format
TicketMessage is represented as JSON objects having the following keys:

JSON KeyTypeRequiredRead onlyCommentExample
IdstringNoYes
Message ID

First message’s ID must be equal to ticket ID.

Example:
First Message: 11701
Second Message: 246733d03f64db3b72af327d0d835ebd
Read more
TicketIdstringYesNoTicket ID11701
FullnamestringNoNoVisitor’s nameJohanna Doe
EmailstringNoNoVisitor’s email[email protected]
CompanystringNoNoVisitor’s companyJdscompany Ltd.
PhonestringNoNoVisitor’s phone #004988373728
IPstringNoNoVisitor’s IP192.168.1.222
CallMeBackbooleanNoYesCallback Requiredtrue
TypeintNoNo
Message Type

[0] = (Incoming) Web
[1] = (Outgoing) Email
[2] = Chat
[3] = (Incoming) Email
Read more
SubjectstringNoNoSubject / URLCan you help?
SenderIdstringNoNoOperator or Visitor Idjohn_doe
ChannelIdstringNoNo  
Commentsarray<int,array<str, str>>NoNo
Ticket Comments

array<index,array<operator_id, comment_text>>
Read more
Attachmentsarray<Attachment>NoYesFile attachments 
EditedintNoYesLast edited time (UNIX Timestamp)1395332206
CreatedintNoYesCreated (UNIX Timestamp)1395332206
Customsarray<int,array<str, str>>NoNo
Custom input field values

array<index,array<input_name, input_value>>
Read more
TextstringNoNoMessage PlaintextHello, please help me.



TicketMessage Functions



Create Ticket Message
Function
As of version 5.2.5.0


POST /api/v2/api.php p_ticketmessage_create=1


Filters


NamePOST KeyTypeRequiredCommentExample
SendEmailResponderp_sendemailresponderboolNoSend autoresponder email to sender of message1
SendEmailReplyp_sendemailreplyboolNoSend operator reply email to receiver of message1
QuoteMessageIdp_quotemessageidstringNoThe Ticket Message ID of the Message the Operator is replying to.90f9cf…


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_ticketmessage_create=1
-d p_data={ "TicketMessage": { "Type": "0", "Customs": "", "ChannelId": "", "Subject": "Can you help?", "Comments": "", "TicketId": "11701", "Text": "Hello, please help me.", "Fullname": "Johanna Doe", "Company": "Jdscompany Ltd.", "Phone": "004988373728", "Email": "[email protected]", "IP": "192.168.1.222", "SenderId": "john_doe" } } -X POST

Response


200 Ok: {
    "TicketMessage": {
        "Type": "0",
        "Customs": "",
        "CallMeBack": "true",
        "ChannelId": "",
        "Attachments": "",
        "Edited": "1395332206",
        "Subject": "Can you help?",
        "Comments": "",
        "TicketId": "11701",
        "Text": "Hello, please help me.",
        "Created": "1395332206",
        "Id": "
First Message: 11701
Second Message: 246733d03f64db3b72af327d0d835ebd", "Fullname": "Johanna Doe", "Company": "Jdscompany Ltd.", "Phone": "004988373728", "Email": "[email protected]", "IP": "192.168.1.222", "SenderId": "john_doe" } }

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


Example: PHP code to add a message to an existing ticket


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_ticketmessage_create"]=1;
            $postd["p_json_pretty"]=1;

            class TicketMessage
            {
                public $Fullname = "Johanna Doe";
                public $TicketId = 11704;
                public $Email = "[email protected]";
                public $Phone = "004988373728";
                public $Type = 0;
                public $Text = "Hello, please help me.";
                public $Subject = "http://www.mywebsite.domain/products";
                public $IP = "217.2.5.1";
                public $Company = "Jdscompany Ltd.";
                //public $Customs = array(array("CustomerNumber","11112726"));
                //public $Comments = array(array("john_doe","comment #1"),array("john_doe","comment #2"));
            }

            $newMessage = new TicketMessage();
            $postd["p_data"]= json_encode(array("TicketMessage"=>$newMessage));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            curl_close($ch);
    ?>
TicketEditor Object Format
TicketEditor is represented as JSON objects having the following keys:

JSON KeyTypeRequiredRead onlyCommentExample
EditorstringYesNoEditor (=Operator) IDjohn_doe
StatusintNoNo
Ticket Status

[0] = Open
[1] = In Progress
[2] = Closed
[3] = Deleted
[4] = Pending
Read more
SubStatusstringNoNoTicket Sub-StatusSub-Status Name
IdstringYesNoTicket ID11123



TicketEditor Functions



Assign Ticket Editor
Function
As of version 5.2.5.0


POST /api/v2/api.php p_ticketeditor_assign=1


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_ticketeditor_assign=1
-d p_data={ "TicketEditor": { "SubStatus": "Sub-Status Name", "Id": "11123", "Editor": "john_doe", "Status": "0" } } -X POST

Response


200 Ok: {
    "TicketEditor": {
        "SubStatus": "Sub-Status Name",
        "Id": "11123",
        "Editor": "john_doe",
        "Status": "0"
    }
}

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


Example: PHP code to assign an operator to a ticket


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_ticketeditor_assign"]=1;
            $postd["p_json_pretty"]=1;

            class TicketEditor
            {
                public $Id = "11967";
                public $Editor = "john_doe";
            }

            $neweditor = new TicketEditor();
            $postd["p_data"]= json_encode(array("TicketEditor"=>$neweditor));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            curl_close($ch);
    ?>
KnowledgeBaseEntry Object Format
KnowledgeBaseEntry is represented as JSON objects having the following keys:

JSON KeyTypeRequiredRead onlyCommentExample
IdstringNoNoUnique ID (32 chars)14t733d03f64db3b72af327d0d835ebd
TagsstringNoNoTags (comma separated)car,sharing,stations
ValuestringYesNoContent (HTML, URL or Filename)
TitlestringYesNoTitleWhere to find car sharing stations?
LanguagesstringNoNoLanguages (comma-separated iso 2 letter code)de,fr
TypeintYesNoResource Type (0=Folder, 1=HTML/Text, 2=Link, 3=Operator File, 4=Customer File)0
ParentIdstringYesNoParent’s Id (root = 1)ae33b353c9174c3f97628067f8104405
IsPublicintNoNoDefines if entry can be found in Knowledgebase1
FulltextSearchintNoNoDefines if fulltext (= content) search will be used1
ShortcutWordstringNoNoShortword for operator clientmyshortcut
GroupIdstringNoNoGroup ID (owner) (LiveZilla 6.1.1.0)support
OwnerIdstringNoNoOperator ID (owner) (LiveZilla 6.1.1.0)d351dc9
AllowBotAccessintYesNoDefines if entry will be used by Virtual Assistance1



KnowledgeBaseEntry Functions



List Knowledgebase Entries
Function
As of version 6.0.0.0


POST /api/v2/api.php p_knowledgebase_entries_list=1


Filters


NamePOST KeyTypeRequiredCommentExample
Show Privatep_show_privateboolNoPrivate (non-public) entries will be returned.1
Idp_idstringNoWill return the entry matching the given Id.14t733d03f64db3b72af327d0d835ebd
Limitp_limitintNoMaximum number of tickets to return.100
Offsetp_offsetintNoIndex where to start returning records (requires Limit parameter).101
Parent Idp_parent_idstringNoAll child nodes of parent will be returned.14t733d03f64db3b72af327d0d835ebd


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_knowledgebase_entries_list=1 -X POST

Response


200 Ok: {
    "KnowledgeBaseEntries": [
        {
            "KnowledgeBaseEntry": {
                "Id": "14t733d03f64db3b72af327d0d835ebd",
                "Tags": "car,sharing,stations",
                "Value": "...",
                "Title": "Where to find car sharing stations?",
                "ParentId": "ae33b353c9174c3f97628067f8104405",
                "Type": 1,
                "OwnerId": null,
                "GroupId": "",
                "Languages": null,
                "IsPublic": 1,
                "FulltextSearch": 1,
                "ShortcutWord": "csstations",
                "AllowBotAccess": 1
            }
        }
    ]
}

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


Example: PHP code to list Knowledge Base Entries


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_knowledgebase_entries_list"]=1;
            $postd["p_json_pretty"]=1;

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            echo "<hr>";
            curl_close($ch);

            $response = json_decode($server_output);

            if(count($response->KnowledgeBaseEntries) == 0)
                exit("No KnowledgeBase entries found");

            foreach($response->KnowledgeBaseEntries as $obj)
            {
                echo "Entry: " . $obj->KnowledgeBaseEntry->Title;
                echo "<br>";
                // further processing ...
            }
    ?>




Create Knowledgebase Entry
Function
As of version 6.0.0.0


POST /api/v2/api.php p_knowledgebase_entry_create=1


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_knowledgebase_entry_create=1
-d p_data={ "KnowledgeBaseEntry": { "Id": "14t733d03f64db3b72af327d0d835ebd", "Tags": "car,sharing,stations", "Value": "...", "Title": "Where to find car sharing stations?", "ParentId": "ae33b353c9174c3f97628067f8104405", "Type": 1, "OwnerId": null, "GroupId": "", "Languages": null, "IsPublic": 1, "FulltextSearch": 1, "ShortcutWord": "csstations", "AllowBotAccess": 1 } } -X POST

Response


200 Ok: {
    "KnowledgeBaseEntry": {
        "Id": "14t733d03f64db3b72af327d0d835ebd",
        "Tags": "car,sharing,stations",
        "Value": "...",
        "Title": "Where to find car sharing stations?",
        "ParentId": "ae33b353c9174c3f97628067f8104405",
        "Type": 1,
        "OwnerId": null,
        "GroupId": "",
        "Languages": null,
        "IsPublic": 1,
        "FulltextSearch": 1,
        "ShortcutWord": "csstations",
        "AllowBotAccess": 1
    }
}

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


Example: PHP code to create a Knowledge Base Entry


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_knowledgebase_entry_create"]=1;
            $postd["p_json_pretty"]=1;

            class KnowledgeBaseEntry
            {
                public $Tags = "car, sharing";
                public $Value = "Content goes here ....";
                public $Title = "Where to find car sharing stations?";
                public $ParentId = "ae33b353c9174c3f97628067f8104405";
                public $Type= 1;
                public $IsPublic = 1;
                public $FulltextSearch = 1;
                public $ShortcutWord = "myshortcut";
                public $AllowBotAccess = 1;
            }

            $newKBEntry = new KnowledgeBaseEntry();
            $postd["p_data"]= json_encode(array("KnowledgeBaseEntry"=>$newKBEntry));
            $ch = curl_init();

            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            curl_close($ch);
    ?>
Cronjob Functions



Execute Cronjob
Function
As of version 7.0.0.3


POST /api/v2/api.php p_cronjob_execute=1


Filters


NamePOST KeyTypeRequiredCommentExample
Send Chat Transcriptsp_send_chat_transcriptsboolYesClosed chats will be archived and chat transcripts will be sent. Call every 10-20 hours.1
Receive Emailsp_receive_emailsboolYesEmails will be downloaded from mailboxes. Call every 2-5 minutes.1
Maintenancep_maintenanceboolYesPruning and optimizing databases. Call every 10-120 seconds.1
Social Mediap_social_mediaboolYesDownload messages from Social Media. Call every 10-120 seconds.1


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_cronjob_execute=1
-d p_cronjob_maintain=1
-d p_send_chat_transcripts=1
-d p_receive_emails=1
-d p_social_media=1 -X POST

Response


200 Ok: "SUCCESS"

Error Codes


403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)


PHP code to execute CronJobs


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_cronjob_execute"]=1;
            $postd["p_send_chat_transcripts"]=1;
            $postd["p_receive_emails"]=1;
            $postd["p_maintenance"]=1;
            $postd["p_social_media"]=1;

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            echo "<hr>";
            curl_close($ch);

            $response = json_decode($server_output);
    ?>

Teste GRÁTIS por 10 dias