Begin building web applications with our quick start guide for the JavaScript Chat UI SDK
At first import ChatBubble component and useConvaiClient hook from convai-chatui-sdk.
Invoke the useConvaiClient
hook in your application, passing characterId
and apiKey
as parameters, then store the returned states in a client
variable for future reference.
In the return statement of your component, render the ChatBubble
component that was imported via the NPM package.
Integrate Convai's conversational services with a Chat UI into your Web Application.
Sign in to Convai and copy your API key. This will help you to converse with the avatar at a later step.
Convai Chat UI SDK is available as an npm package. Run the following command in the root of your React project to install the package.
npm install convai-chatui-sdk@latest
LTS Version: 0.0.4
Convai's JavaScript Chat UI SDK provides you with a set of tools to integrate Convai's conversational AI services with a Chat UI into your web-based applications. Our Chat UI package is designed to drastically expedite the process of establishing a chat environment for web-based applications. With streamlined integration, developers can now effortlessly setup an interactive, fully customizable chat interface in no time.
Before you begin with the integration, make sure, you have created an account with Convai and have your own API-Key.
Dive into the detailed guide to understand and utilize the properties that can be passed to your Chat Bubble component for enhanced customization and control.
In the ChatBubble component, there are three main properties:
A chatHistory property to determine whether to display the chat history.
A chatUiVariant property to specify the chat variant to display.
A set of properties returned by useConvaiClient
which are essential for fetching user and NPC texts.
The set of properties that are mandatory to be returned by the useConvaiClient (You can follow the JavaScript SDK tutorial to set up your own custom useConvaiClient hook) for the Chat Bubble to work as expected are:
npcText : Stores the text returned by Npc.
userText: Stores the user text.
convaiClient: Stores the state of convai client and is used by Chat Bubble to set session Id.
keyPressed: Changes whenever the user presses the key and starts speaking.
characterId: Used by the chat bubble to store and retrieve chat history.
setUserText: Used by Chat Bubble component to reset the Chat History.
setNpcText: Used by the Chat Bubble component to reset the Chat History.
setEnter: Used by the textbox to send the textbox content to the client whenever the user press enter.
These are the properties that can be optionally passed by the custom useConvaiClient hook. If you are using the inbuilt useConvaiClient hook you can use these properties:
npcName: Name that will be shown on the chat UI for your character.
userName: Name that will represent user on the chat UI.
gender: Returns the gender of your avatar ( Can be used to set up animations).
avatar: Gives the model link of your avatar which can be used to load your 3D model to the scene.
actionText: Returns the action text that represents the action Npc has been asked to perform.
There are 4 types of chat variants that you can choose from:
Toggle History Chat
Unified Compact Chat
Sequential Line Chat
Expanded Side Chat