LiveZilla Live Chat
1-Click Demo
EN  DE Please sign in or register Hi


LiveZilla API V2





Chat
Chat Object Format
Chat is represented as JSON objects having the following keys:

JSON Key Type Required Read only Comment Example
UserIdstringYesNoUnique identifier of the user, max 32 charsd9729feb63a1a010
ChatIdstringNoYesThe chat ID11123
FullnamestringNoNoUser full nameJohn Doe
EmailstringNoNoUser emailjohn@doe.com
CompanystringNoNoUser companyDoe Ltd.
PhonestringNoNoUser phone004977311894432
CustomsstringNoNoCustom input field values

array<index,array<input_name, input_value>>
GroupstringYesNoChat target group idsupport
OperatorstringNoNoChat target operator idfc6a5761d39598c
CountrystringNoNoISO two letter county codeES
LanguagestringNoNoISO two letter language codeDE
IdentifierstringNoNoCustom indentifier textThis is an API chat
IPstringNoNoUser IP111.111.111.111
WebhookstringYesNoWebhook URL to receive operator messageshttp://website.com/hook.php


Chat Functions


Create Chat Session
Function
As of version 8.0.0.0


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


Filters


Name POST Key Type Required Comment Example


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_chat_create=1
-d p_data={ "Chat": { "UserId": "d9729feb63a1a010", "Fullname": "John Doe", "Email": "john@doe.com", "Company": "Doe Ltd.", "Phone": "004977311894432", "Customs": "", "Group": "support", "Operator": "fc6a5761d39598c", "Country": "ES", "Language": "DE", "Identifier": "This is an API chat", "IP": "111.111.111.111", "Webhook": "http:\/\/website.com\/hook.php" } } -X POST

Response


200 Ok: {
    "Chat": {
        "ChatId": 12212,
        "UserId": "d9729feb63a1a010",
        "Fullname": "John Doe",
        "Email": "john@doe.com",
        "Company": "Doe Ltd.",
        "Phone": "004977311894432",
        "Customs": "",
        "Group": "support",
        "Operator": "fc6a5761d39598c",
        "Country": "ES",
        "Language": "DE",
        "Identifier": "This is an API chat",
        "IP": "111.111.111.111",
        "Webhook": "http:\/\/website.com\/hook.php"
    }
}

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 initiate a chat session


    <?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_chat_create"]=1;
            $postd["p_json_pretty"]=1;

            class Chat
            {
                public $UserId = "d9729feb63a1a010";
                public $Fullname = "Johanna Doe";
                public $Email = "johanna@domain.com";
                public $Phone = "004988373728";
                public $Company = "Doe Ltd.";
                public $Group = "support";
                public $Country = "us";
                public $Language = "en";
                public $Identifier = "API TEST CHAT";
                public $Webhook = "http://localhost/webhook.php";
                public $IP = "217.2.5.1";
                public $Customs = array(array("CustNumb","11194"));
            }

            $newChat = new Chat();
            $postd["p_data"]= json_encode(array("Chat"=>$newChat));

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



Add Chat Message
Function
As of version 8.0.0.0


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


Filters


Name POST Key Type Required Comment Example


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_chat_add_message=1
-d p_data={
"Message": {
"ChatId": "12212",
"Text": "Hi, I have a question"
}
} -X POST

Response


200 Ok: {
    "Message": {
        "ChatId": 12212,
        "Text": "Hi, I have a question"
    }
}

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 initiate a chat session


    <?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_chat_add_message"]=1;
            $postd["p_json_pretty"]=1;

            class Message
            {
                public $Text = "Hey, here's my message!";
                public $ChatId = "13771";
            }

            $newMessage = new Message();
            $postd["p_data"]= json_encode(array("Message"=>$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);
    ?>





Something missing?


If you find anything missing please let us know and we will add the missing structures right away. Thanks.