Google+

Follow Us:

Developers Network
Currently Being Moderated

Signed Rest Demo of Adding Variables to an Existing Visit Using the Visit API with Java

By using the sample code below, you agree to the following terms and conditions:

You agree that you bear all risks associated with using or relying on any content or sample codes found in the code library. LivePerson does not warrant the accuracy, reliability, completeness, usefulness, non-infringement, or quality of any data or content found in the code library.  If you install or enable any content from the code library for use or for use with the services provided by LivePerson (“Services”), you acknowledge and agree that (1) the terms of any Master Services Agreement or any other Agreement in which LivePerson provides Services to you (“Services Agreement”), shall not apply to your use or download of any content from the code library, even if used for the interaction with the Services provided to you by LivePerson under a Services Agreement and (2) LivePerson has no responsibility or liability for any content provided in the code library. The content provided in the code library is provided on an “AS IS” basis.  LivePerson will not support any of the content found in the code library.  LivePerson makes no warranty: (i) that content in the code library will meet your requirements or expectations, (ii) that your access to the code library will be uninterrupted, timely or error-free, or (iii) any errors in the code library will be corrected.  LIVEPERSON EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT RELATED TO YOUR USE OF THE CODE LIBRARY.

An application is a solution that is built on top of the LivePerson platform and is developed using LivePerson’s Open Platform architecture - Read more on Getting Started with Applications

Overview

This is a sample application written in Java that demonstrates how to implement the LivePerson Visit API to add "session level" custom variables to an existing LivePerson monitored website visit using Signed REST. LivePerson provides this example under the MIT License to maximize the flexibility for integrating LivePerson's Open Platform code into commercial or open source products.

Downloads

  • Source code of sample application written in Java that demonstrates Signed REST, Sample_Admin_Console_VisitAPI_Signed.doc, Sample_of_Custom_Variables_VisitAPI.doc and demovisitapisample.html - Signed Rest Demo of Adding Variables to an Existing Visit Using the Visit API with Java.zip

Getting Started

 

1. Review the document named Getting Started with Applications about creating the Application Key and Application Secret needed to build LivePerson Open Platform applications.

 

2. Review the OAuth for Signed REST Communication reference about OAuth 1.0 and the use of LivePerson's Verification Code (OAuth Access Token and Access Secret) in Signed REST applications.

 

3. Review the Send Visit ID Directly to Third-Party Application Flow Diagram inside the REST Visit API Reference.

 

4. The Visit API (REST) requires you to send LivePerson the unique identifier from your CRM for this particular visitor as the custom variable customerID via the Monitor Code mtagconfig.js or by creating a custom variable under the Variables action type for your rule in the Admin Console. For example, this is the customerID that was created for this particular visitor in the Admin Console.

 

ParameterValue

Variable Name

customerID

Variable Value

eric@demo.com

 

5. Create a custom variable named myLPVisitApiURL under the Variables action type for your rule in the Admin Console. This will allow developers to see the LivePerson Visitor API URL created for the specific website visitor inside the LivePerson Agent Console. The Sample_of_Custom_Variables_VisitAPI.doc shows how the custom variables should be displayed to the agent. For example, you could see the value https://dev.liveperson.net/api/account/P67488665/visit/H848607670179349552K1855/customVariables for the custom variable myLPVisitApiURL.

 

ParameterValue

Variable Name

myLPVisitApiURL

Variable Value

${visitorInfo.visitCustomVarUrl}

 

6. Review the code of this sample application that demonstrates the use of the Visit API with Signed REST. This application writes messages to the Java console.

 

7. Develop your application using code snippits from this sample application.

 

8. Once you open the web page, demovisitapisample.html in a browser window, you should see the LivePerson Visitor API URL custom variable myLPVisitApiURL inside the LivePerson Agent Console. You can use the value of this custom variable to set the value of lpVisitCustomVarUrl in your application. Before you can use this web page, update the lpServer in line 6 with the LivePerson server and the lpNumber in line 7 with your LivePerson account number.

 

9. Update the lpVisitCustomVarUrl variable inside your application and then debug it to see if your custom variable appears inside the LivePerson Agent Console. Below is a list of responses from LivePerson to determine if your application was successful or not in using the Visit API that will be displayed inside your Java console.

 

MessageRespCodeRespMsgRespErrorMsg

Successful

200

OK

Visitor id does not exist

404

Not Found

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error><time>2011-01-04T10:31:55.138-05:00</time><message>No such Visit ID.Perhapse session was ended.</message><internalCode>12</internalCode></error>

LP server error has occurred

405

Method Not Allowed

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error><time>2011-01-04T10:34:24.584-05:00</time><message></message><internalCode>28</internalCode></error>

 

10. Since you know that your application works, you will need to convert your stand-a-lone application into a web listener for the LivePerson's Send Notification to Server action to work properly. Review the application action Send Notification to Server inside the Application Actions Reference.

 

11. Your web listener will need to read the HttpServletRequest form data parameters sent to your servlet and parse out the customerID and the URL. For example, my production application would expect to receive the parameters customerID=eric@demo.com&URL=https://dev.liveperson.net/api/account/P67488665/visit/H7911158383372919522K1577/customVariables from LivePerson. The value for the parameter URL would be used to dynamically set the lpVisitCustomVarUrl variable inside your web listener.

 

12. Once you have create your web listener, create the Send Notification to Server under the Third Party Notifications action type for your rule in the Admin Console. These are the values used for this sample application. The Sample_Admin_Console_VisitAPI.doc shows how the action should be set-up for a rule. The account must be enabled for the creation of Third Party Notifications.

 

ParameterValue

Domain Name

www.livepersonhosting.com

URL Path

WebChat/servlet/WebVisitAPIListener

Visitor Notification

Visitor Notification

Message

customerID=$!{vars.emailaddress}&URL=${visitorInfo.visitCustomVarUrl}

Protocol

http or https

Headers

A:B

 

13. You can use the demovisitapisample.html to test your web listener to see if your custom variable appears inside the LivePerson Agent Console.

 

Comments

Delete Document

Are you sure you want to delete this document?