Skip to main content

Overview

Starting from version 0.2.0 of React UIKit, the AI functionality is enabled by default and based on OpenAI’s chat GPT. The QuickBlox AI for React UIKit 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

Requirements

The minimum requirements for using AI features are:
  • JS QuickBlox SDK v2.15.5
  • React v.18.0
  • TypeScript v.4.9.3
  • React UIKit v0.2.0

AI Answer Assist

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

How to use in React UIKit

In React UIKit version greater then 0.4.0 with JS QuickBlox SDK v2.17.0 to enable QuickBlox AI answer assistant you should set up the AIAnswerAssistWidgetConfig in the configAIApi segment of the QBConfig.ts file to provide your Smart ChatAssist ID from your QuickBlox admin panel. Review your AI Agent To get ID of AI Agent to use it as smartChatAssistantId param follow the steps below:
  1. Navigate to the Dashboard => YOUR_APP => AI Agent page.
  2. Choose the ID of the AI Agent you want to update and click on it.
  3. Edit the AI Agent settings.
  4. Click the Save button to save changes.
To utilize the QuickBlox AI Answer Assist React hook to communicate directly with the OpenAI API , you should configure the AIAnswerAssistWidgetConfig section in the configuration file, as shown in the code snippet provided below.
TypeScript
WarningThe code snippets below are not recommended for use with React UIKit version greater than 0.4.0, because they will be deprecated. In the modern version of our React UIKit, you do not have the ability to make AI Assist customizations.
Enabling QuickBlox AI answer assistant in React UIKit version less then 0.4.0 involves just 2 straightforward actions:
  1. Set up the AIAnswerAssistWidgetConfig in the configAIApi segment of the QBConfig.ts file to provide your API Key.
  2. Optionally, initialize the AIAssist property within the QuickBloxUIKitDesktopLayout (or MessageView) component for customizing the appearance or logic of the AI Assist component.
There are two ways to use the QuickBlox AI Assist answer:
  1. Direct: Access Open AI directly from your client code. The AIAssist component use a raw Open AI token. This is suitable for development or demos, but it’s not the recommended approach for production due to security considerations.
  2. Proxy: Access Open AI through a proxy server. The AIAssist component use QuickBlox user session token with a proxy server. This is the recommended method for production environments, ensuring a more secure and controlled setup.
Directly using configuration To utilize the QuickBlox AI Answer Assist React hook to communicate directly with the OpenAI API , you should configure the AIAnswerAssistWidgetConfig section in the configuration file, as shown in the code snippet provided below. The token should be stored in the apiKey property in the configAIApi section in the QBConfig.ts file. This contains information about configurations for all AI features . After that theAIAssist component will communicate directly with the OpenAI API.
TypeScript
Proxy using configuration To utilize the QuickBlox AI Answer Assist React hook to communicate through a proxy server (not directly) with OpenAI API, you should configure the AIAnswerAssistWidgetConfig section in the configuration file, as shown in the code snippet provided below. The fields api, servername, port, and sessionToken need to be configured within the proxyConfig section for communication with the proxy server.
TypeScript
We recommend using our proxy server, which you can access through this link. Please ensure that you are using the latest release.
AI Answer Assist customization You have the ability to control AI Answer Assist from code as follows: set it to enabled/disabled, customize the appearance of the component icon, and modify its operational logic. To enable or disable AIAssist use the following code:
JSX
The QuickBloxUIKitDesktopLayout is a layout component located within the provider section. We explored an example of its usage in our UIKit documentation, specifically in the Send your First Message section. To customize the appearance of the component icon, you should create your own React custom hook that must return an object of the AIMessageWidget interface and update the code within the renderWidget method. For modifying its operational logic, you should create your own React custom hook that must return an object of the AIMessageWidget interface and update the code within the textToWidget method. The interface AIMessageWidget has next structure: Example code of custom hook:
TypeScript
To set up your own realization you should use the property AIAssist inQuickBloxUIKitDesktopLayout or in MessageView components like this: Let’s modify the QuickBloxUIKitDesktopLayout component from “Send your first message” page :
JSX
in MessageView component se detail information on this page :
JSX
You can compare the configuration of the QuickBloxUIKitDesktopLayout component with the AI Widget to the default view of the QuickBloxUIKitDesktopLayout component from the “Send your first message” page .

How to use the feature as a standalone library

You can use logic of the React hook features separately from our UI kit is possible by connecting the library as described below. The library qb-ai-answer-assistant contains QBAIAnswerAssistant object wich provide all nececry features. install standalone library QBAIAnswerAssistant can be installed using Node Package Manager. To include it in your JS based project, follow these command:
PowerShell
add to own project To use QBAIAnswerAssistant in your project, follow these steps:
  1. Import the QBAIAnswerAssistant module:
JavaScript
  1. Create an array of ChatMessage objects representing the chat history:
JavaScript
or
JavaScript
  1. Call the rephrase method to generate translate using an API key:
JavaScript
Alternatively, you can use a QuickBlox user token and a proxy URL for more secure communication:
JavaScript

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 in React Kit

In React UIKit greater than 0.4.0 with JS QuickBlox SDK v2.17.0, to enable QuickBlox AI Translate, you should set up the AITranslateWidgetConfig in the configAIApi segment of the QBConfig.ts file to provide your Smart ChatAssist ID from your admin panel. Review your AI Agent To get ID of AI Agent to use it as smartChatAssistantId param, follow the steps below:
  1. Navigate to the Dashboard => YOUR_APP => AI Agent page.
  2. Choose the ID of the AI Agent you want to update and click on it.
  3. Edit the AI Agent settings.
  4. Click the Save button to save changes.
To utilize the QuickBlox AI Translate React hook to communicate directly with the OpenAI API , you should configure the AITranslateWidgetConfig section in the configuration file, as shown in the code snippet provided below.
TypeScript
WarningThe code snippets below are not recommended for use with React UIKit version greater than 0.4.0, because they will be deprecated. In the modern version of our React UIKit, you do not have the ability to make AI Translate customizations.
Enabling QuickBlox AI Translate in React UIKit version less then 0.4.0 involves just 2 straightforward actions:
  1. Set up the AITranslateWidgetConfig in the configAIApi segment of the QBConfig.ts file to provide your API Key.
  2. Optionally, initialize the AITranslate property within the QuickBloxUIKitDesktopLayout (or MessageView) component for customizing the appearance or logic of the AI Translate component.
There are two ways to use the QuickBlox AI Translate:
  1. Direct: Access Open AI directly from your client code. The AITranslate component use a raw Open AI token. This is suitable for development or demos, but it’s not the recommended approach for production due to security considerations.
  2. Proxy: Access Open AI through a proxy server. The AITranslate component use QuickBlox user session token with a proxy server. This is the recommended method for production environments, ensuring a more secure and controlled setup.
Directly using configuration To utilize the QuickBlox AI Translate React hook to communicate directly with the OpenAI API , you should configure the AITranslateWidgetConfig section in the configuration file, as shown in the code snippet provided below. The token should be stored in the apiKey property in the configAIApi section in the QBConfig.ts file. This contains information about configurations for all AI features . AFter that theAITranslate component will communicate directly with the OpenAI API.
TypeScript
Proxy using configuration To utilize the QuickBlox AI Translate React hook to communicate through a proxy server (not directly) with OpenAI API, you should configure the AITranslateWidgetConfig section in the configuration file, as shown in the code snippet provided below. The fields api, servername, port, and sessionToken need to be configured within the proxyConfig section for communication with the proxy server.
TypeScript
We recommend using our proxy server, which you can access through this link. Please ensure that you are using the latest release.
AI Translate customization You have the ability to control AI Translate from code as follows: set it to enabled/disabled, customize the appearance of the component icon, and modify its operational logic. To enable or disable AI Translate use the following code:
JSX
The QuickBloxUIKitDesktopLayout is a layout component located within the provider section. We explored an example of its usage in our UIKit documentation, specifically in the Send your First Message section. To customize the appearance of the component icon, you should create your own React custom hook that must return an object of the AIMessageWidget interface and update the code within the renderWidget method. For modifying its operational logic, you should create your own React custom hook that must return an object of the AIMessageWidget interface and update the code within the textToWidget method. The interface AIMessageWidget has next structure: Example code of custom hook:
TypeScript
To set up your own realization you should use the property AITranslate inQuickBloxUIKitDesktopLayout or in MessageView components like this: Let’s modify the QuickBloxUIKitDesktopLayout component from “Send your first message” page :
JSX
in MessageView component se detail information on this page :
JSX
You can compare the configuration of the QuickBloxUIKitDesktopLayout component with the AI Widget to the default view of the QuickBloxUIKitDesktopLayout component from the “Send your first message” page .

How to use the feature as a standalone library

You can use logic of the React hook features separately from our UI kit is possible by connecting the library as described below. The library qb-ai-translate contains QBAITranslate object wich provide all nececry features. install standalone library QBAITranslate can be installed using Node Package Manager. To include it in your JS based project, follow these command:
PowerShell
add to own project To use QBAITranslate in your project, follow these steps:
  1. Import the QBAIAnswerAssistant module:
JavaScript
  1. Create an array of ChatMessage` objects representing the chat history:
JavaScript
or
JavaScript
  1. Call the translate method to generate translate using an API key:
JavaScript
Alternatively, you can use a QuickBlox user token and a proxy URL for more secure communication:
JavaScript

AI Rephrase

QuickBlox provides answer prephrase message functionality that helps users allows you to rephrase the response for an outgoing message in the chosen tone..

How to use in React UIKit

Enabling QuickBlox AI Rephrase Message in React UIKit involves just 2 straightforward actions:
  1. Set up the AIRephraseWidgetConfig in the configAIApi segment of the QBConfig.ts file to provide your API Key.
  2. Optionally, initialize the AIRephrase property within the QuickBloxUIKitDesktopLayout (or MessageView) component for customizing the appearance or logic of the AI Rephrase component.
There are two ways to use the QuickBlox AI Rephrase:
  1. Direct: Access Open AI directly from your client code. The AIRephrase component use a raw Open AI token. This is suitable for development or demos, but it’s not the recommended approach for production due to security considerations.
  2. Proxy: Access Open AI through a proxy server. The AIRephrase component use QuickBlox user session token with a proxy server. This is the recommended method for production environments, ensuring a more secure and controlled setup.
Directly using configuration To utilize the QuickBlox AI Rephrase Message React hook to communicate directly with the OpenAI API , you should configure the AIRephraseWidgetConfig section in the configuration file, as shown in the code snippet provided below. The token should be stored in the apiKey property in the configAIApi section in the QBConfig.ts file. This contains information about configurations for all AI features . AFter that theAIRephrase component will communicate directly with the OpenAI API.
TypeScript
Proxy using configuration To utilize the QuickBlox AI Rephrase Message React hook to communicate through a proxy server (not directly) with OpenAI API, you should configure the AIRephraseWidgetConfig section in the configuration file, as shown in the code snippet provided below. The fields api, servername, port, and sessionToken need to be configured within the proxyConfig section for communication with the proxy server.
TypeScript
We recommend using our proxy server, which you can access through this link. Please ensure that you are using the latest release.
AI Rephrase customization You have the ability to control AI Rephrase Message from code as follows: set it to enabled/disabled, customize the appearance of the component icon, and modify its operational logic. To enable or disable Answer Assist use the following code:
JSX
The QuickBloxUIKitDesktopLayout is a layout component located within the provider section. We explored an example of its usage in our UIKit documentation, specifically in the Send your First Message section. To customize the appearance of the component icon, you should create your own React custom hook that must return an object of the AIMessageWidget interface and update the code within the textToWidget method. For modifying its operational logic, you should create your own React custom hook that must return an object of the AIMessageWidget interface and update the code within the textToWidget method. The interface AIMessageWidget has next structure: Example code of custom hook:
TypeScript
To set up your own realization you should use the property AIRephrase inQuickBloxUIKitDesktopLayout or in MessageView components like this: Let’s modify the QuickBloxUIKitDesktopLayout component from “Send your first message” page :
JSX
in MessageView component se detail information on this page :
JSX
You can compare the configuration of the QuickBloxUIKitDesktopLayout component with the AI Widget to the default view of the QuickBloxUIKitDesktopLayout component from the “Send your first message” page .

How to use the feature as a standalone library

You can use logic of the React hook features separately from our UI kit is possible by connecting the library as described below. The library qb-ai-rephrase contains QBAIRephrase object wich provide all nececry features. Install standalone library QBAIRephrase can be installed using Node Package Manager. To include it in your JS based project, follow these command:
PowerShell
Add to own project To use QBAIRephrase in your project, follow these steps:
  1. Import the QBAIRephrase module:
JavaScript
  1. Create an array of ChatMessage objects representing the chat history:
JavaScript
or
JavaScript
  1. Call the rephrase method to generate translate using an API key:
JavaScript
Alternatively, you can use a QuickBlox user token and a proxy URL for more secure communication:
JavaScript