A Developers Blog: October 2016

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

Saturday, October 29, 2016

How To Connect To The Engagement History API Through Postman

I have gotten a lot of request from people on how to connect to the APIs that are available from LivePerson using Postman, so I decided to share how to do this here.

In order to follow along with this tutorial, you will need the API keys that are available for Engagement History API, and you will need access to the Postman App. To get these keys, you can log into the LiveEngage console, and grab them from them from the API tab under data sources, which is on the campaigns tab. If you are not sure on how to setup your keys, you can learn how to do so here.

If you do not already have Postman installed, you can learn more about it and install it from here: https://www.getpostman.com/

If you would just like to import a template of the query into Postman, you can do so here: https://www.getpostman.com/collections/6bd9d4cc64bbee6843f1

Let's get started.

1) The first thing you need to do is find out what the base URI is for your account. This will be needed to make any API calls. In Postman, make a new GET request with the following URL: https://api.liveperson.net/api/account/{Your Account Number}/service/engHistDomain/baseURI.json?version=1.0

You will need to update the '{Your Account Number}' with just your account number. For example, your updated link should look similar to this: https://api.liveperson.net/api/account/56072331/service/engHistDomain/baseURI.json?version=1.0

2) Now, click on the Send button and you should get a 200 response with your base URI.



3) In a new tab in Postman, update the request to be a POST request, and add the following URL to the request: https://{YOUR BASE URI}/interaction_history/api/account/{YOUR ACCOUNT NUMBER}/interactions/search?offset=0&limit=10

You will need to update the '{YOUR BASE URI}' and the 'YOUR ACCOUNT NUMBER}' parts of the URL with your LiveEngage account number, and with the base URI that you received in the steps before. For example, your updated link should look similar to this: https://va-a.enghist.liveperson.net/interaction_history/api/account/56072331/interactions/search?offset=0&limit=10


4) For the API call to be successful, you will need to add the following to the request: a body, a content type header, and an OAuth 1 header. To add the Body, click on Body, and choose "raw" as the type. Add the following parameters to the body: {"start":{"from":1477052344000,"to":1477657144000}}


The data that you just added is the timeframe that you would like to query the API for. The time is entered as an epoch timestamp in milliseconds. To quickly get the date that you would like to use in an epoch timestamp format, you can use this website here: http://www.epochconverter.com/. Note: You may need to update the timeframe for the query to work with your account.

5) Next, lets add the Content-Type header to the request. Click on "Headers" tab, and in the "key" field type in: Content-Type, and in the "value" field type in: application/json.


6) Lastly, you just need to add your OAuth 1 header to the API call. Click on "Authorization" tab, and in the type drop down choose "OAuth 1.0". In the fields that appear, you will need to add your API keys from LiveEngage:
  • Consumer Key - Your App Key
  • Consumer Secret - Your Secret
  • Token - Your Access Token
  • Token Secret - You Access Token Secret
Also, on the right hand side, make sure the check for "Add params to header" is checked.


Once you fill in your keys, click on the "Update Request" button to update your request.

Now, click on the "Send" button, and you should get a 200 response back with your chat transcripts.


You can import a template for this query directly into Postman by clicking this link here: https://www.getpostman.com/collections/6bd9d4cc64bbee6843f1


Summary: This tutorial showed you how to use Postman to query the Engagement History API that is available from LivePerson.

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

Labels: , , , ,