This article should provide you with the details to get you up and running with Live Assist for Android. It's comprised of three main sections:
Quick Start
The Quick Start repository can be found in CBA GitHub Repository.
This repository contains a gradle project that demonstrates the setup and usage of the Live Assist framework.
It contains a build.gradle file which is configured to download the latest version of the Live Assist Library.
Running the Sample.
Clone this repo:
git clone https://github.com/cafexcomms/liveassist-demo-android.git
Where do I find my account number?
See: Find Your Account Number to obtain your account number.
Set your account identifier in the Android resources (/app/src/main/res/values/integer.xml)
<?xml version="1.12" encoding="utf-8"?> <resources> <integer name="account_identifier">3121150</integer> </resources>
run the gradle command to install or open the project in android studio
./gradlew installDebug
Where is the Live Assist used in the sample?
The sample adds the LiveAssistView component to the MainActivity xml and class. Basic setup and configuration are implemented in this file.
private void onCreateLiveAssist() { LiveAssistView liveAssistView = (LiveAssistView) findViewById(R.id.live_assist); liveAssistView.loadWithConfig(this.getLiveAssistConfig()); }
Adding Live Assist to an existing Android Project
I have my own Android project, how do I add and use Live Assist?
Adding the release repository
Add the release repository to your top-level build file
allprojects { repositories { maven { url "http://repo.liveassistfor365.com/releases" } jcenter() } }
Add the live assist library as a dependency to your new application (build.gradle)
api 'com.cafex:liveassist-android:1.4.+'
Add the Support v4 Library as a dependency to your application.
Android Manifest Modifications
Open AndroidManifest.xml
Set the Android name to the LiveAssistApplication class
android:name="com.cafex.liveassist.LiveAssistApplication"
If already have your own application class defined, you must Add Live Assist to an existing Android Application class and manage the global application state yourself.
Adding the LiveAssist to your layouts
Add the LiveAssistView to your layout xml and modify your attributes
<com.cafex.liveassist.LiveAssistView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/live_assist" />
Java Modifications
Add the imports to your file
import com.cafex.liveassist.LiveAssistChatStyle; import com.cafex.liveassist.LiveAssistConfig; import com.cafex.liveassist.LiveAssistView;
Create a Configuration
int accountId = 123456; String[] sections = {"mobile","support"}; LiveAssistChatStyle chatStyle = LiveAssistChatStyle.AUTO; LiveAssistConfig liveAssistConfig = new LiveAssistConfig(accountId,sections,chatStyle);
Configure the View with the configuration
LiveAssistView liveAssistView = (LiveAssistView) findViewById(R.id.live_assist); liveAssistView.loadWithConfig(liveAssistConfig);
Further Features
Changing the Style of the Window
Live Assist can run in three types of visual modes.
This setting is passed as a parameter when you create your configuration.
liveAssistConfig = new LiveAssistConfig( accountId, sections, LiveAssistChatStyle.AUTO );
FULL_SCREEN will open the chat window full screen and is the recommended setting if you are targeting mobile devices.
POP_UP will open the chat window in a small window and is the recommended setting if you are targeting tablets.
AUTO will use popups for tablets and full screen for mobile devices. This is the recommended setting for projects targeting mobile and tablets.
Setting Sections
You can use sections to filter the visibility of individual chat buttons. They do not apply to chat windows or survey windows already open. Once the chat window or survey window is open, it will remain open until a visitor closes it, setting the section will not hide an already open chat or survey engagement. See: Using Sections to categorize your website
You can set the sections using the setSections method on the live assist view.
Invoking this method will cause the live assist view to reload.
String[] sections = {"mobile","support"}; liveAssistView.setSections(sections);
Registering Listeners
You can implement application-specific behavior, such as generating notifications if chat messages arrive while the application is minimized, using these two methods to register listeners:
public void registerChatMessageReceiver(LiveAssistChatMessageReceiver receiver)
public void registerChatStateListener(LiveAssistChatStateListener listener)
Note that the default notification behavior can be disabled.
LiveAssistConfig.disableDefaultNotifications()
How do I authorize a chat?
Assume you have a recent build of the sample app, including an appropriate version of the SDK, installed on your device.
- Open the LiveAssistFor365 sample app from your app launcher.
- The app will open. The exact appearance will depend on the version you have installed.
- Open the kebab menu at the top and select Settings.
- The settings we are interested in are Issuer Identifier and Subscriber.
- The issuer is the identifier for the issuer of the JWT being used to authenticate. Enter the value here and click OK.
- Subscriber is the identifier given to the user of the app by the issuer of the JWT. Enter the value here and click OK.
Using issuer and subscriber in your own app:
In the case of the sample, the mechanism for getting the values in is deliberately artificial for the sake of flexibility. In your own app, the issuer identifier may be a hard-coded string or a value retrieved from a REST API. Similarly, some generated user identifiers would be supplied for the subscriber value.
String iss = getIssuer();
String sub = getSubscriber();
liveAssistConfig = new LiveAssistConfig(
livePersonAccountId,
sections,
chatStyle
);
These values should be passed into the existing LiveAssistConfig object, via setIss(String) and setSub(String) respectively.
liveAssistConfig.setIss(iss);
liveAssistConfig.setSub(sub);
See:
How do I set engagement attributes?
You can set engagement attributes using the setEngagementAttributes method on the live assist view.
public void updateEngagementAttributesExample() { final String jsonCartExample = "{\"numItems\":6,\"type\":\"cart\",\"total\":5.6,\"products\":[{\"product\":{\"price\":0.8,\"name\":\"Cream Cake\",\"category\":\"ANDROID CAKE\",\"sku\":\"CAKE-1234\"},\"quantity\":2},{\"product\":{\"price\":1,\"name\":\"Ice Bun\",\"category\":\"CAKE\",\"sku\":\"CAKE-2468\"},\"quantity\":4}]}"; liveAssistView.setEngagementAttributes(jsonCartExample); }
Permissions Requirements
The Live Assist Library will add the required permissions to your manifests when you add them to your project.
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
The Library will ask for the display over other apps' permission when a co-browse is initialized.
If this is denied then the application will terminate the co-browse session.
What is the size of the LiveAssist for Microsoft Dynamics365 Android SDK?
The size of the Android SDK is about 1.2MB, but the size can vary slightly based on which compiler is used.