Skip to main content

A8Chat Android SDK

Getting Started

The Autonom8 A8Chat SDK enables you to integrate A8Chat bot functionality into your Android applications. This SDK provides flexible chat features, customizable themes, and support for user-specific configurations.

Installation

Step 1 - Add Maven Repository:

Add the following code to your root build.gradle file to add the Autonom8 Maven repository:

Gradle
allprojects {
repositories {
...
maven {
url "https://maven.autonom8.com/artifactory/public"
}
}
}

Step 2 - Add Dependency:

Add the following code to your app-level build.gradle file to add the A8Chat dependency:

Gradle
implementation 'com.autonom8:a8chat:1.1.0'

Step 3 - Sync Project:

Sync your project to download and configure the A8Chat library.

Using the A8Chat SDK

Step 1: Initialize the Bot with your credentials.

To initialize the bot in your Android application, configure the Bot object with the required parameters and theme settings. This setup allows the bot to display customized user interfaces and themes within your app.

Java
Map<String, String> variablesMap = new HashMap<>();
variablesMap.put("name", "John Doe");
variablesMap.put("age", "25");
String variablesJson = new Gson().toJson(variablesMap);

Bot bot = new Bot.Builder(MainActivity.this)
.setAppKey("your_app_key")
.setBotHandle("your_bot_handle")
.setDisplayName("display_name_for_bot")
.setOrgId("your_organization_id")
.setOrgName("your_organization_name")
.setBaseUrl("https://your_base_url.com")
.setEmail("user_email@example.com")
.setIsLive(true) // Set to true for production/live mode
.setUserId("user_unique_id")
.setVariables(variablesJson) // Pass the JSON string here
.setChatTheme(new ChatTheme(
null,
new Widget(
null, null,
new Header(
null,
new Color("#008000"), // Header color
new Color("#008000"), // Header text color
null,
new Title(new Color("#000000")) // Title color
),
null, null,
new UserInput(
null,
null,
new Color("#000000"),
null,
null,
null,
null,
"I'm here...", // Placeholder text in input
null
)
),
null
))
.build();
note

Mandatory Fileds: AppKey, BotHandler, userId, email, orgName, baseUrl, isLive, and OrgId.

Note: Replace placeholders like "your_app_key", "your_bot_handle", and others with values specific to your application setup.

Step 2: Launch the Chat

Call the startActivity() method on the bot object to launch the A8Chat interface.

Java
bot.startActivity();

Customization

The A8Chat SDK provides flexibility in designing a custom chat interface. The ChatTheme class allows you to specify different colors, text styles, and widget properties for the chat window.

ChatTheme Class

Use the ChatTheme class to set up your preferred chat window theme. Here's an example of the ChatTheme data structure:

Java
data class ChatTheme(
val text: Text?,
val widget: Widget?,
val widgetIcon: WidgetIcon?
): Serializable

Parameters

  • text: Customize the text settings in the chat.
  • widget: Define the appearance and behavior of widgets in the chat.
  • widgetIcon: Configure the icons used within the chat widgets.

Using ChatTheme in Initialization

Customize the appearance of the chat bot by adjusting the ChatTheme parameters during bot initialization. This configuration allows for a fully tailored user interface that aligns with your app's design.