A Developers Blog

This blog has moved to GitHub, and you should be redirected shortly...

Wednesday, February 10, 2016

LiveEngage - Engagement History API Program To Send Email

Today I wanted to share with you a program I made that will allow you to use the Engagement History API to send out emails for transcripts that have a particular keyword.

The program will use the API to pull all of your chat transcripts for the previous day that contain a certain keyword, and then it will send it to an email address that you specify. The program makes use of the SendGrid API in order to send the emails.

One example use case for this tool is if you wanted to get an email every time someone answered dissatisfied on your post chat survey, you could use that keyword and it will automatically pull those transcripts.

In order to use the program, you will need to have a SendGrid account with an API key enabled on it. SendGrid allows for you to send up to 12,000 emails for free a month, and if you need to send more they offer very cheap plans. You will also need to have the Engagement History API enabled on your LiveEngage account in order to use the program.

If you are interested in checking out the program or getting the source code, you can find it on GitHub here: https://github.com/scottwestover/LiveEngageExamples/tree/master/APIs/Java-EHAPIProgram

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

Labels: , , ,

Wednesday, December 16, 2015

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.

Labels: , , , , ,