This article should provide you 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 an 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 is 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.2.+'
Add the Support v4 Library as a dependency to your application.
Android Manifest Modifications
Open AndroidManifest.xml
Set android name to the LiveAssistApplication class
android:name="com.cafex.liveassist.LiveAssistApplication"
If already have your 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 you 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 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 popup 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);
How do I authorize a chat?
implement the LiveAssistDelegate interface
public class LiveAssistActivity extends Activity implements LiveAssistDelegate
Set the method name and LiveAssistDelegate on your LiveAssistConfig Object before you initialize the LiveAssistView
liveAssistConfig.setJavascriptMethodName("You authorization method here…"); liveAssistConfig.setLiveAssistDelegate(this);
Implement the authoriseChatWithCallback method and pass your JWT token to the authorise method.
@Override public void authoriseChatWithCallback(LiveAssistAuth liveAssistAuth) { String jwt = "ADD YOUR JWT HERE" liveAssistAuth.authorise(jwt); }
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 it 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.
Minimum supported SDK version.
The minimum version supported version of Android is 6.0 (API Level 23).
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.