Integrating Convai character chatbot services in Roblox game.
Roblox is an online game platform and game creation system developed by Roblox Corporation that allows users to program games and play games created by other users. This provides a perfect platform to develop games with intelligent AI-based NPCs with which the player can interact and experience a new way of story progression or gameplay altogether.
Roblox environment doesn't support many essential features required to enjoy the power of the character API endpoints to their full potential.
Roblox doesn't allow the creation of audio files
We cannot utilize the audio response from Convai as there is no easy way to create an audio file and play it within the game.
Roblox doesn't allow microphone access
We cannot record audio from the user and pass that directly to the server for processing and generating a response. We are limited to sending only text data through the request body and receive and display only text-data from the response.
Interact with an intelligent character in a different environment and explore it.
This is another simple game that you can access, ask questions and get them answered by the assistant bot.
Points to Remember:
For beginners, we provide 50 sample conversations that they can carry out with the characters they want, without setting up their API Key. To continue with more conversation, please get your API Key from our site and enter the value in the respective input box at the bottom left corner, and press ENTER.
Please refer to , for further steps.
To play the game follow the given steps:
Get your API Key from our website. It is necessary to carry on any conversation in the game after the free quota has expired.
Visit the link given above for the game.
Click on the green Play button. That will open Roblox locally for you to play.
You are ready to converse with the character
Click on the Understood button, to close the notifications. Read it once though. Enter the API Key in the bottom left section of the screen. Remember to press ENTER after entering the value to register it in the backend.
Now click on the Chatbox Icon or press the "/" icon on the keyboard to start a conversation. Type out the text and press ENTER.
That's it. You can continue your conversation and keep exploring the environment.
Character Conversation API - Code Example for Roblox integration with Convai.
The following piece of code is the most essential section to make a successful call to the Convai server to get a response in a conversation with a character.
Refer to Character API Doc for more details on the endpoint.
This portion of the code is present in the GlobalFunctions script in the Convai Roblox Integration Demo that you just tried out in the previous section.
The call is handled by the Chat_Character file present within the character model in the game Workspace.
The above function is called in the chatbox implementation in the demo game. Here is an overview of what each part is doing:
The function accepts the message we get from the user. We send that along with the sessionID, and characterID. We also pass the API Key that we have set previously.
HttpService allows HTTP requests to be sent from game servers. Details.
Now for the most important portion of the code:
Notice how Content-Type is set to "application/x-www-form-urlencoded". This is the only acceptable way to send form-data in Roblox. Since the endpoint only accepts form data, we had to parse the data in a suitable format to send it to the server.
While the Body of the request might look like a complicated string, it is actually quite simple. To break it down into its simple components, it can be viewed as:
The value for voiceResponse is set to False. Since we have no utility of the audio data that the server will generate, we just completely skip that audio generation. The reason is mentioned in the Constraints before.
The rest of the part is a simple response handling code. Since the response, we receive is JSON data, we have to decode that on the client side to read its content:
That concludes our discussion on the /getResponse API.
API Request code from Roblox
Interact with the character in a simple implementation from Convai
Download the game file: Download
Current Version: Ver 1.1 - Simple Character API Integration
This is a very simple game that you can access to try out some sample conversations with your character.
Points to Remember:
The game loads with a sample character by default. You can interact with this default character or you can choose to replace it with your own character that you created from our site or through our APIs. Just enter the corresponding Character ID in the respective input box at the bottom left corner of the screen, press ENTER and you are good to go.
For beginners, we provide 50 sample conversations that they can carry out with the characters they want, without setting up their API Key. To continue with more conversation, please get your API Key from our site and enter the value in the respective input box at the bottom left corner, and press ENTER.
Please refer to , for further steps.
To play the game follow the given steps:
Get your API Key from our website. It is necessary to carry on any conversation in the game after the free quota has expired.
Get the character ID of the new character that you have created in the Character Creator Tool. If you do not have one, there is no need to worry. The game comes loaded with a sample character to explore.
Visit the link given above for the game.
Click on the green Play button. That will open Roblox locally for you to play.
You are ready to converse with the character
Click on the Understood button, to close the notifications. Read it once though. Enter the API Key and the Character ID in the bottom left section of the screen. Enter the value in each of the text boxes and press Enter. Remember to press ENTER after entering the value to register it in the backend.
Now click on the Chatbox Icon or press the "/" icon on the keyboard to start a conversation. Start by saying "Hi!" and pressing ENTER.
That's it. You can continue your conversation and keep testing your characters.