Access Offline Messages and Block IPs for Live Chat

Banckle Banckle · April 29, 2014 · Short URL: https://vator.tv/n/369a

Code Samples for Access Offline Chat Messages & Block IPs for Live Chat in Cloud

Banckle has released Cloud APIs to allow developers to create their own live support applications for their website to manage their customers and offers many useful features. Banckle has also enhanced their existing apps to ensure the best customer services.

 

Banckle.Chat for Cloud API is a smart live chat tool for your websites which allows you to initiate live chat session with a customer, routine monitoring of visitors' activity, managing user chat sessions or sending replies to offline messages and offers many more features.

 

RESTful API from Banckle for live chat allows website owners to perform chat visitors analytics for the browsing visitors to analyze their patterns. It returns information such as time zone, email, city, language, keywords and browser version of your website visitors as well as their activity on your website. With this live chat tool, you can keep an offline record of all customer conversations held by different team members on different platforms. This RESTful API can be used with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more and on any platform. Below you can find all details about how to access Banckle Cloud API for live chat and also the code for some of its features. Follow the steps given below and you can easily access Banckle Cloud API for live chat.

 

Prerequisites

You can easily access Banckle.Chat API by using Swagger API Explorer.

In order to use Swagger API Explorer, you must have:

  1. A valid Banckle Account. Sign Up on Banckle.
  2. A valid Banckle API key. You will get API key from your Dashboard after successful login
  3. A Valid Banckle Authorize Token which you can get from here.
  4. After you provide a valid login info, API Key and Token values you are ready to use Swagger API Explorer for Banckle.Chat API

REST Code Example to Get all Offline Messages in C#

string api_key = "...";

string session_resource = "...";

string request_url = "https://chat.banckle.com/v3/offlineMessages.js?start=1&end=10";

 

WebRequest request = HttpWebRequest.Create(new Uri(request_url));

request.Headers.Add("banckle-client-api-key", api_key);

request.Headers.Add("X-Resource", session_resource);

 

WebResponse response = request.GetResponse();

Stream response_stream = response.GetResponseStream();

string response_body = new StreamReader(response_stream).ReadToEnd();

response_stream.Close();

 

JObject response_json = JObject.Parse(response_body);

JArray messages = (JArray)response_json["return"];

foreach (JObject message in messages)

{

        Console.WriteLine("Id: {0}", message["id"]);

        Console.WriteLine("Message text: {0}", message["message"]);

        Console.WriteLine();

}

Give your API key in api_key parameter and X-Resource value (you will get X-Resource value from swagger) in session_resource parameter.

Below is the response you will get when you run the above code.

Response

 

{
    "return" : [
        {
            "message" : "Ggg",
            "id" : "532fe8c3-71a8-481c-91e4-33564358b1d3",
            "locked" : false,
            "timestamp" : 1385872163000,
            "visitorNickname" : "Yy",
            "visitorEmail" : "hhh@fff.bbb",
            "visitor" : "2B3F383A01B43424B5FE4BD205352F6F",
            "read" : true,
            "department" : "86a46bf6-d991-47fc-b782-6e41d70701e8",
            "replyContent" : null,
            "translateTo" : null,
            "translateContent" : null,
            "replyDate" : 1386689849000,
            "repliedBy" : "xxx.yyy",
            "repliedOutside" : true,
            "spam" : false
        }
    ],
    "@status_code" : 200
}

REST Code Example to Block IP for live chat in C#

string api_key = "...";
string session_resource = "...";
 
JObject request_json = new JObject();
request_json.Add("ip", new JValue("123.123.123.123"));
string request_body = request_json.ToString();
string request_url = "https://chat.banckle.com/v3/blockedIps.js";
 
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(request_url));
request.Headers.Add("banckle-client-api-key", api_key);
request.Headers.Add("X-Resource", session_resource);
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = request_body.Length;
 
StreamWriter request_writer = new StreamWriter(request.GetRequestStream());
request_writer.Write(request_body);
request_writer.Close();
 
WebResponse response = request.GetResponse();
Stream response_stream = response.GetResponseStream();
string response_body = new StreamReader(response_stream).ReadToEnd();
response_stream.Close();
 
JObject response_json = JObject.Parse(response_body);
Console.WriteLine("Blocked: id={0}", response_json["return"]);
 
Response

 

{
    "return" : "9ab9915a-809a-4e21-b1a2-6bdfd4c73973",
    "@status_code" : 200
}
 
 

Overview: Banckle.Chat for Cloud API

 

Banckle.Chat for Cloud APIs provides useful live chat APIs to develop new and enhance your existing customer support and engagement web applications. With Banckle Chat API for websites, you can personalize your website visitors’ experience and turn them into potential customers. This web chat API has REST based architecture, which allows you to easily manipulate information and resources using simple HTTP requests and responses. 

 

More about Banckle.Chat for Cloud API

 

-          Homepage of Banckle.Chat for Cloud API

-          Visit Banckle.Chat for Cloud API Marketplace 

-          Post your technical questions/queries to Banckle Chat Forum

-          Receive notifications about latest news and supported features by subscribing to Banckle Chat blog

 

Contact Information:


Suite 163, 79 Longueville Road

Lane Cove, NSW, 2066

Australia

Banckle – Social and Business Applications

support@banckle.com

Phone: +1 214 329 1520