Introduction

Campaigns are the cornerstone of LiveEngage - the place where every digital engagement is created and organized. By using campaigns, brands can target specific audiences in order to achieve their business goals, such as increasing sales or generating leads.

Using the Monitoring APIs, brands can:

  • Report on the customer’s journey inside the app

  • Get engagements based on the reported SDEs

  • Route conversations to a specific skill (based on engagements)

While web messaging allows automatic capturing of events (using the LE Tag), when using campaigns for In-App Messaging, it is up to the app to report the various events by using the In-App Monitoring APIs as will be explained in this guide.

Monitoring APIs

The Monitoring APIs provide brands access to the LivePerson monitoring system. The APIs can be used for reporting engagement attributes and to retrieve engagements. The eligibility for an engagement is based on campaigns and an engagement's definitions.

Monitoring APIs include two APIs:

  • sendSDE - Sends engagement attributes to LivePerson. Should be used whenever the app would like to report on an engagement attribute.

  • getEngagement - In case that there is a matching campaign and engagement, getEngagement will return an engagement. The method can be used to send engagement attributes (as part of the request body) as well.

Code Samples

Initialize SDK with Monitoring

// Creating init object for the Monitoring APIs
MonitoringInitParams monitoringInitParams = new MonitoringInitParams("AppInstallId");

// Initializing the SDK with the created MonitoringInitParams
LivePerson.initialize(context, new InitLivePersonProperties(brandId, appId, monitoringInitParams, new InitLivePersonCallBack() {

  @Override
  public void onInitSucceed() {
    ...
  }

  @Override
  public void onInitFailed(Exception e) {
    ...
  }
}));

Monitoring parameters example

// Creating Identities array.
ArrayList<LPMonitoringIdentity> identityList = new ArrayList<>();
// Creating the identity Object and adding to the array
// ConsumerId - unique and non-guessable identifier of the consumer. Should be the same consumer id provided in the JWT
// BrandIssuer - Issuer, who identified the consumer - usually the brand.
LPMonitoringIdentity monitoringIdentity = new LPMonitoringIdentity("ConsumerId", "BrandIssuer");
identityList.add(monitoringIdentity);

// Creating entryPoints object
JSONArray entryPoints = new JSONArray();
entryPoints.put("http://www.liveperson-test.com");
entryPoints.put("sec://Food");
entryPoints.put("lang://De");

// Creating engagement attributes
JSONArray engagementAttriutes = new JSONArray();
JSONObject purchase = new JSONObject();
purchase.put("type", "purchase");
purchase.put("total", 11.7);
purchase.put("orderId", "Dx342");

JSONObject lead = new JSONObject();
lead.put("leadId", "xyz123");
lead.put("value", 10500);

engagementAttriutes.put(purchase);
engagementAttriutes.put(lead);

MonitoringParams monitoringParams = new MonitoringParams("PageId", entryPoints, engagementAttriutes);

GetEngagement API

// Calling getEngagement and providing the created identityList and monitoringParams (includes entryPoints and engagementAttriutes)
LivepersonMonitoring.getEngagement(context, identityList, monitoringParams, new EngagementCallback() {
			@Override
			public void onSuccess(@NotNull LPEngagementResponse lpEngagementResponse) {
				...
			}

			@Override
			public void onError(@NotNull MonitoringErrorType errorType, @Nullable Exception exception) {
				...
			}
		});

SendSde API

// Sending engagement attributes and providing the created identityList and monitoringParams (includes entryPoints and engagementAttriutes)
LivepersonMonitoring.sendSde(context, identityList, monitoringParams, new SdeCallback() {
  @Override
  public void onSuccess(@NotNull LPSdeResponse lpSdeResponse) {
    ...
  }

  @Override
  public void onError(@NotNull MonitoringErrorType errorType, @Nullable Exception exception) {
    ...
  }
});

Open conversation with CampaignInfo

ConversationViewParams conversationViewParams = new ConversationViewParams();
// Creating a campaignInfo object
CampaignInfo campaignInfo = new CampaignInfo(campaignId, engagementId, engagementContextId, sessionId, visitorId);
// Adding the created CampaignInfo to the conversationViewParams
conversationViewParams.setCampaignInfo(campaignInfo);

LPAuthenticationParams lpAuthenticationParams = new LPAuthenticationParams(LPAuthenticationParams.LPAuthenticationType.AUTH);
lpAuthenticationParams.setAuthKey(authCode);

// Presenting the conversation window. If a new conversation starts, it will be routed according to the engagement in campaignInfo
LivePerson.showConversation(activity, lpAuthenticationParams, conversationViewParams);

Notes & Best Practices

  • Please follow the steps in the Campaigns for Messaging guide before adding the implementation to a mobile app.

  • In order to use the APIs, the SDK should be initialized with the MonitoringInitParams object.

  • In order to start a conversation with a specific campaign and engagement, a CampaignInfo object should be provided to the ConversationViewParams object.

  • A monitoring session is a 6 hours window. All SDEs which will be reported during the session will be aggregated.

  • In case of not reporting any SDEs (idle) for 30 minutes, a new session will be started when reporting the next SDE.