Campaigns are the cornerstone of Conversational Cloud — 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 Web 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.

Prerequisites

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

  • The SDK must be initialized with the MonitoringInitParams object.

Notes and Best Practices

  • To start a conversation with a specific campaign and engagement, provide a CampaignInfo object to the ConversationViewParams object.

  • A monitoring session is a 6-hours window. All SDEs that report during the session get aggregated.

  • If not reporting any SDEs (idle) for 30 minutes, a new session starts when reporting the next SDE.

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 are a matching campaign and engagement, getEngagement returns an engagement.

Code Samples

conversationViewParams

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(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);

getEngagement API

Use this API to send engagement attributes (as part of the request body). As an optional parameter, you can pass MontoringParams, which includes PageId, Entry Points, and Engagement Attributes for routing the conversation. Available parameters include:

  • context: application context

  • consumerID: an optional brand app consumer ID

  • monitoringParams: an instance of includes optional PageId, JSONArray of Entry Points and a JSONArray of Engagement Attributes

  • EngagementCallback: operation callback: onSuccess() response with LPEngagementResponse that contains pageId, sessionId, visitorId and engagementDetailsList onError() response with the MonitoringErrorType

// 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) {
				
			}
		});

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("https://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);

sendSde API

Use this API to report engagement attributes (SDEs). Available parameters include:

  • context: application context

  • consumerID: brand app consumer ID

  • monitoringParams: an instance of LPMonitoringParams that includes an optional Array of Entry Points and an optional dictionary of Engagement Attributes. An additional optional parameter is PageID, which you use for Page identification for sending events on the current engagement. LPSdeResponse and LPtEngagementResponse received the PageID.

  • SdeCallback: operation callback: onSuccess() response with LPSdeResponse that contains pageId, sessionId and visitorId onError() response with the MonitoringErrorType.

// 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) {
    
  }
});