Mobile applications have proven to be a significant component of business with the advent of smartphones. Businesses offer a range of services through their mobile phone applications for better customer engagement. To improve users' interest in apps, developers endeavor to include top-notch customer service features.
The Guided Conversations (GC) mobile SDK for Android helps developers build a conversational self-service platform to achieve the best customer service. GC replaces human interactions with built-in conversations. It directs customers to appropriate solutions according to their responses during conversations.
Setting up the SDK
You need to integrate the GC widget within your Android app to create and register the add-on in Zoho Desk.
- In Zoho Desk, go to Setup > GENERAL > Guided Conversations.
- In the Setup pane, on the left, under General, click Guided Conversations. Click GC Widgets.
The GC Widgets pane will appear. It displays the created widgets. See more: how to create the widget. - Click the Share button () on the right side of the widget you want to embed.
A Share Options window will appear.
4. Click MOBILE SDK.
A new section called Code Snippet will appear. This section displays the following:
Org ID - Specifies the unique ID of the organization.
Widget ID - Specifies the unique ID of the selected widget.
Domain - Specifies the unique URL of your organization.
These details are essential for initializing the ZohoGCSDK in your app.
Integrating the SDK within the Android app
After setting up the SDK, you need to integrate the ZohoGCSDK within the Android app using Maven.
To integrate the SDK within your app, include the following code in the root-level build.gradle file.
Include the below dependency code in the dependencies section of the app level build.gradle file.
dependencies {
implementation 'com.zoho.gc:chat:1.0.5'
}
The ZohoGCSDK is compatible with the following android versions
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
kotlin_version = 1.5.20
Displaying Guided Conversations
The following keys are essential to call the methods for displaying the conversation AI in your app.
The values of these keys appear under the Code Snippet section on the setup page of the ASAP add-on in Zoho Desk.
SHOW BOT:
Kotlin
ZohoGC.getInstance(context).show(activity, orgId, widgetId, domain)
Java
ZohoGC.Companion.getInstance(context).show(activity,orgId, widgetId, domain);
Setting up location block
To enable location block, please follow the below steps:
1. Get the API key for Google Maps from Google.
2. Go to the Androidmanifet.xml file and add the below lines. Add the generated map API key as well.
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_MAP_API_KEY" />
3. Open the strings.xml file and add the following line:
<string name="zoho_gc_places_api_key">YOUR_MAP_API_KEY</string>
Search option:
The search option enables the user to search for a location and share it. This option will be displayed by default. If not required, follow the below method in your preferred language to hide it:
Note: The "search option" for searching for an address is a paid service.
Kotlin
ZohoGCUtil.setHideLocationSearch(true);
Java
ZohoGCUtil.setHideLocationSearch(true);
Session Variables
These variables are dynamically retrieved during the conversation. These variables are org-specific and accessible across flows.
You can perform the following actions with the session variable:
Set Session Variable:
Kotlin
val sessionVariableMap = HashMap<String, Any>()
sessionVariableMap.apply
{
this["name"] = "exampleName"
this["value"] = "exampleValue"
}
val sessionVariableList = ArrayList<HashMap<String, Any>>()
sessionVariableList.add(sessionVariableMap)
ZohoGC.getInstance(context).setSessionVariables(sessionVariableList)
Java
HashMap<String, Object> sessionVariableMap= new HashMap<>();
sessionVariableMap.put("name","exampleName");
sessionVariableMap.put("value","exampleValue");
ArrayList<HashMap<String,Object>> sessionVariableList= new ArrayList<>();
sessionVariableList.add(sessionVariableMap);
Update Session Variable:
Kotlin
val sessionVariableMap = HashMap<String, Any>()
sessionVariableMap.apply
{
this["name"] = "exampleName"
this["value"] = "exampleValue"
}
val sessionVariableList = ArrayList<HashMap<String, Any>>()
sessionVariableList.add(sessionVariableMap)
ZohoGC.getInstance(context).updateSessionVariables(sessionVariableList)
Java
HashMap<String, Object> sessionVariableMap= new HashMap<>();
sessionVariableMap.put("name","exampleName");
sessionVariableMap.put("value","exampleValue");
ArrayList<HashMap<String,Object>> sessionVariableList= new ArrayList<>();
sessionVariableList.add(sessionVariableMap);
ZohoGC.Companion.getInstance(context).updateSessionVariables(sessionVariableList);
Customizing the theme:
You can also customize the default light and dark themes to make the SDK look more like your application.
Note: The default theme is the light theme. Kotlin
val light: ZDTheme = ZDTheme.Builder(false).build()
Java
ZDTheme light = new ZDTheme.Builder(false).build();
If you want to switch the theme to dark mode, use the below method:
Kotlin
val dark: ZDTheme = ZDTheme.Builder(true).build()
Java
ZDTheme dark = new ZDTheme.Builder(true).build();
Theme Builder provides additional color customization options such as setColorAccent and setTextColorPrimary.
Kotlin
val light: ZDTheme = ZDTheme.Builder(false).build()
val dark: ZDTheme = ZDTheme.Builder(true).build()
ZohoGCUtility.themeBuilder = light
Java
ZDTheme light = new ZDTheme.Builder(false).build();
ZDTheme dark = new ZDTheme.Builder(true).build();
ZohoGCUtility.INSTANCE.setThemeBuilder(light);
Note: Updating the SDK's theme is different from setting a theme type. The SDK will either be in a dark or light theme, based on the theme type you have set.
Clearing local data
Use the following method to delete any local data that has been saved inside the SDK, such as databases and files:
Kotlin
ZohoGC.getInstance(context)
.clearData(widgetId,object : ZDChatCallback.ZDClearDataCallback {
override fun onSuccess() {}
override fun onFailed(exception: Exception) {}
})
Java
ZohoGC.Companion.getInstance(context).clearData(widgetId,new ZDChatCallback.ZDClearDataCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(Exception exception) {
}
});
SDK logging
By default, logs are disabled for the SDK. To get the debug logs printed in logcat, enable the logs by the following method:
Kotlin
ZohoGC.getInstance(context).enableLog(true)
Java
ZohoGC.Companion.getInstance(context).enableLog(true);
Release Notes
1.0.5
-Forced network protocol to use HTTP/1.1
1.0.4
-Enhanced visuals with a refreshed appearance.
-Resolved bugs and optimized performance for a smoother user experience.
-Expanded customization options with the introduction of new colors.
1.0_beta03
-The location component was added. For more information, refer here. ​
1.0
-Will be required to call clearData method with widgetId.