LiveEngage - Connecting To The Engagement History API In Java Tutorial

The purpose of this tutorial is to show you how to connect to the Engagement History API in Java.

The Engagement History API is a REST API that is offered through LivePerson that allows you to pull your chat transcripts without having to manually go through and export them. In order to connect to the API, you will need to get a set of API keys from LivePerson and install them on your account. Once you have done this, you will need to send an OAuth 1 request to the server in order to access your transcripts.

If you are not familiar with OAuth 1, you can read more about it here:  http://oauth.net/core/1.0/


For this tutorial, I am using Eclipse Mars 4.5.0, Scribe 1.3.7, and Maven. However, you should be able to follow along if you are using a different IDE.

In Eclipse, you will need to create a new Maven Project. Once you have done this, open the pom.xml file for your project, and add the following dependency:

<dependency>
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<version>1.3.7</version>
</dependency>

In order to use Scribe to make an OAuth call, we will need to define a new provider class that will be used by the OAuthService object. If you are not familar with Scribe, you can read more about it here: https://github.com/scribejava/scribejava

Now, in your src/main/java folder, you will want to create a new class called EHAPI.java. This class is going to extend the DefaultApi10a class. Once the class is created, you will need to add the following code to it:

Now that we have our provider, we will need to create a new class that is going to call the API and display the results to the console.

So, in your src/main/java folder, you will need to create a new class called EngagementHistory.java. Once the class is created, you will need to add the following code to it:

Basically, we are using Scribe to create our OAuth service, and once we do this we our using our credentials for the API to create and sign our OAuth request. Once this is done, we send the request and print it to the console. Please see the comments in the code for what each line is doing.

You can download the complete code on GitHub from here:  https://github.com/scottwestover/LPEngagementHistoryAPIExamples


Summary: This tutorial showed you how to connect to the Engagement History API in Java by using Scribe. You can build upon this tutorial by adding the option to allow the user to input a date range, convert the response into a transcript file that is in a readable format, or even send the responses to a database.

I hope you enjoyed this tutorial. If you have any questions or comments, please feel free to post them below.