Skip to content

Koredotcom/android-kore-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Kore.ai Android SDK

Kore.ai offers SDKs tailored for specific platforms to help developers quickly embed chatbot functionality into their custom applications.
With minimal coding, you can integrate the Kore.ai chat widget and enable users to interact naturally via conversational UI.


Overview

The Kore.ai Android SDK facilitates smooth communication with Kore.ai bots using WebSocket.
This repository also contains a sample application that you can modify to fit your bot configuration needs.


Getting Started

Requirements

  • A service for generating JWT tokens (used for authentication).
  • Bot SDK credentials:
    • Log into the Kore.ai Bots platform.
    • Go to your bot project in the Bot Builder.
    • Enable the Web/Mobile Client channel.
    • Create or select an SDK app to get your Client ID and Client Secret.

Reference Images:

Enable webclient
Enabling Web/Mobile Client Channel

Credentials
Retrieving Client ID and Secret


Integration Methods

1. Integration with UI

Setup Steps

  1. Copy korebot and korebotsdklib modules into your project.
  2. Update settings.gradle:
    include ':korebot', ':korebotsdklib'
  3. Add dependencies in build.gradle:
    implementation(project(':korebot')) {
        exclude module: 'support-v4'
    }
    implementation(project(':korebotsdklib')) {
        exclude module: 'support-v4'
    }

Bot Initialization

Inside your application:

SDKConfig.initialize(
    botId,
    botName,
    clientId,
    clientSecret,
    identity,
    jwtToken,
    serverUrl,
    brandingUrl,
    jwtServerUrl
);

Optional configurations:

// To set custom data if you required
SDKConfig.setCustomData(getCustomData());
// To set query params if you required
SDKConfig.setQueryParams(getQueryParams());
// Flag to use the Webhook instead of socket then make it "true"
SDKConfig.isWebHook(false);
// Flag to show or hide icon for the bot chat conversation
SDKConfig.setIsShowIcon(true);
// Flag to show chat conversation icon at the top the view
SDKConfig.setIsShowIconTop(true);
// Flag to show or hide time stamp of each conversation message
SDKConfig.setIsTimeStampsRequired(true);
// Flag to show or hide action bar in GenericWebviewActivity
SDKConfig.setIsShowActionBar(true);
// Flag to show or hide attachments icon in footer fragment
SDKConfiguration.OverrideKoreConfig.showAttachment = true;
// Flag to show or hide Speech to text(ASR) icon in footer fragment
SDKConfiguration.OverrideKoreConfig.showASRMicroPhone = true;
// Flag to show or hide Text to speech icon in footer fragment
SDKConfiguration.OverrideKoreConfig.showTextToSpeech = true;

To open the chat window:

Intent intent = new Intent(getApplicationContext(), NewBotChatActivity.class);
Bundle bundle = new Bundle();
bundle.putBoolean(BundleUtils.SHOW_PROFILE_PIC, false);
bundle.putString(BundleUtils.BOT_NAME_INITIALS, "B");
intent.putExtras(bundle);
startActivity(intent);

πŸ“˜ Sample App with UI:
Kore.ai Android SDK Sample


2. Headless Integration (Without UI)

Setup Steps

  1. Only include the korebotsdklib module in your project.
  2. Add this to settings.gradle:
    include ':korebotsdklib'
  3. Add dependency in build.gradle:
    implementation(project(':korebotsdklib')) {
        exclude module: 'support-v4'
    }

Bot Integration

  1. Implement the SocketConnectionListener interface.
  2. Connect the bot:
    BotClient botClient = new BotClient(this);
    botClient.connectAsAnonymousUser(jwt, botName, botId, this);
  3. Send messages:
    botClient.sendMessage("Hello Bot");
    botClient.sendMessage("Hello Bot", attachmentsList);

πŸ“˜ Sample App without UI:
Headless SDK Sample


Gradle Integration Guide

With UI

  1. Add the dependency:
    implementation 'com.github.Koredotcom:android-kore-sdk:10.14.2'
  2. Configure the SDK as described above.
  3. Launch chat window:
    Intent intent = new Intent(getApplicationContext(), NewBotChatActivity.class);
    Bundle bundle = new Bundle();
    bundle.putBoolean(BundleUtils.SHOW_PROFILE_PIC, false);
    bundle.putString(BundleUtils.BOT_NAME_INITIALS, "B");
    intent.putExtras(bundle);
    startActivity(intent);
  4. Customize templates or fragments:
// To override existing template or add new template
SDKConfig.setCustomTemplateViewHolder("link", LinkTemplateHolder.class);
// To show your custom content fragment instead of existing
SDKConfig.addCustomContentFragment(new CustomContentFragment());
// To show your custom footer fragment instead of existing
SDKConfig.addCustomFooterFragment(new CustomFooterFragment());
// To show your custom header fragment instead of existing
SDKConfig.addCustomHeaderFragment(new CustomHeaderFragment());

πŸ”— See CustomTemplateInjection Guide
πŸ”— See CustomFragmentInjection Guide


Without UI

  1. Add JitPack to project/build.gradle:
    maven { url 'https://www.jitpack.io' }
  2. Add dependency in app/build.gradle:
    implementation 'com.github.Koredotcom.android-kore-sdk:korebotsdklib:10.14.2'
  3. Configure your bot as described previously.

Extra Features

Push Notifications

Subscribe:

PushNotificationRegistrar registrar = new PushNotification(requestListener);
registrar.registerPushNotification(context, userId, accessToken);

Unsubscribe:

registrar.unsubscribePushNotification(context, accessToken);

Disconnect from Bot

To terminate the bot session:

botClient.disconnect();

Using Webhook Mode

Switch to API/Webhook-based communication:

SDKConfig.isWebHook(true);

License

Β© Kore.ai, Inc.
Licensed under the MIT License. See LICENSE file for details.

About

SDK for Android

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 11

Languages