AI Features

AI Features base on SmartChat Assistants

Overview

Starting from version 4.2.0 of QuickBlox Android SDK, the AI functionality is enabled and based on our SmartChat Assistants. The QuickBlox Android SDK provides a range of features to enhance the chat experience. With essential messaging functionalities such as answer assistant, users can engage in more interactive conversations.

Supported features

NameDescription
AI Answers AssistProvides answers based on chat history to selected message.
AI TranslateProvides translation based on chat history to selected incoming message.

Requirements

The minimum requirements for using AI features are:

  • QuickBlox Android SDK v4.2.0
  • Quickblox account with activated SmartChat Assistants

Visit our Key Concepts page to get an overall understanding of the most important QuickBlox concepts.

Visit our Smart Chat Assistant overview page to get an overall understanding of the most important SmartChat Assistants concepts.

Before you begin

  1. Register a QuickBlox account. This is a matter of a few minutes and you will be able to use this account to build your apps.
  2. Configure QuickBlox SDK for your app. Check out our Setup page for more details.
  3. Create a user session to be able to use QuickBlox functionality. See our Authentication page to learn how to do it.
  4. Create or update your SmartChat Assistant. See our Smart Chat Assistant documentation to learn how to do it.

Enable AI Extensions

  1. Navigate to the Dashboard => YOUR_APP => AI Extensions page
  2. Select the checkboxes for the features you want to enable.
  3. Click the Save button to save changes.

Review your SmartChat Assistant

To get ID of SmartChat Assistant to use it as smartChatAssistantId param follow the steps below:

  1. Navigate to the Dashboard => YOUR_APP => SmartChat Assistant page
  2. Choose the ID of the SmartChat Assistant you want to update and click on it.
  3. Edit the SmartChat Assistant settings.
  4. Click the Save button to save changes.

AI Answer Assist

QuickBlox provides answer assistant functionality that helps users effortlessly send various answers considering chat history.

How to use Answer Assist

String smartChatAssistantId = "XXXXXXXXXXXXXXXXXXXXXXXX";
String messageToAssist = "What is Quickblox?";

List<QBAIAnswerAssistHistoryMessage> history = new ArrayList<>();

history.add(new QBAIAnswerAssistHistoryMessageImpl(Role.USER, "Hi"));
history.add(new QBAIAnswerAssistHistoryMessageImpl(Role.ASSISTANT, "Hello! How can I assist you today?"));

QB.ai.answerAssist(smartChatAssistantId, messageToAssist, history).performAsync(new QBEntityCallback<QBAIAnswerAssistResult>() {
    @Override
    public void onSuccess(QBAIAnswerAssistResult qbaiAnswerAssistResult, Bundle bundle) {
        String answer = qbaiAnswerAssistResult.getMessage();
        // handle answer
    }
  
    @Override
    public void onError(QBResponseException exception) {
        // handle error
    }
});
val smartChatAssistantId = "XXXXXXXXXXXXXXXXXXXXXXXX"
val messageToAssist = "What is Quickblox?"

val history: MutableList<QBAIAnswerAssistHistoryMessage> = ArrayList()
history.add(QBAIAnswerAssistHistoryMessageImpl(Role.USER, "Hi"))
history.add(QBAIAnswerAssistHistoryMessageImpl(Role.ASSISTANT, "Hello! How can I assist you today?"))

QB.ai.answerAssist(smartChatAssistantId, messageToAssist, history)
    .performAsync(object : QBEntityCallback<QBAIAnswerAssistResult?> {
        override fun onSuccess(qbaiAnswerAssistResult: QBAIAnswerAssistResult?, bundle: Bundle) {
            val answer = qbaiAnswerAssistResult?.message
            // handle answer
        }
        
        override fun onError(exception: QBResponseException) {
            // handle error
        }
    })
Parameter nameTypeDescription
smartChatAssistantIdStringThis field should hold your actual Smart Chat Assistant ID that you'll receive from the Quickblox account. This ID is used to authenticate your requests to the AI service.
messageToAssistStringThe message you want to get an answer for.
historyArray of ObjectConversation history. Used to add context. Each object of the array should have two fields: 'role' and 'message'. The field role should contain one of the next values: Role.USER or Role.ASSISTANT. The field message should be a String with a chat message.

AI Translate

QuickBlox offers translation functionality that helps users easily translate text messages in chat, taking into account the context of the chat history.

How to use AI Translate

String smartChatAssistantId = "XXXXXXXXXXXXXXXXXXXXXXXX";
String textToTranslate = "Hola!";
String languageCode = "en";

QB.ai.translate(smartChatAssistantId, textToTranslate, languageCode).performAsync(new QBEntityCallback<QBAITranslateResult>() {
    @Override
    public void onSuccess(QBAITranslateResult qbaiTranslateResult, Bundle bundle) {
        String translation = qbaiTranslateResult.getMessage();
        // handle translation
    }
  
    @Override
    public void onError(QBResponseException e) {
        // handle error
    }
});
val smartChatAssistantId = "XXXXXXXXXXXXXXXXXXXXXXXX"
val textToTranslate = "Hola!"
val languageCode = "en"

QB.ai.translate(smartChatAssistantId, textToTranslate, languageCode)
    .performAsync(object : QBEntityCallback<QBAITranslateResult> {
        override fun onSuccess(qbaiTranslateResult: QBAITranslateResult, bundle: Bundle) {
            val translation = qbaiTranslateResult.message
            // handle translation
        }
        
        override fun onError(e: QBResponseException) {
            // handle error
        }
    })
Parameter nameTypeDescription
smartChatAssistantIdStringThis field should hold your actual Smart Chat Assistant ID that you'll receive from the Quickblox account. This ID is used to authenticate your requests to the AI service.
textToTranslateStringText to translate.
languageCodeStringtTranslation language code.