Availability Notice
The Voice Chat feature is available to selected customers only.
If you don't have access, please reach out to the Ejento Support Team to request it.
Overview#
This guide walks you through the complete process of using the Generate Token for Voice Call API to power a real-time voice call experience in your frontend — from calling the API to connecting through LiveKit.
Step 1 — Call the Generate Token API#
Endpoint#
POST /response-service/api/v2/agents/{agent_id}/voice-chat
Path Parameters#
| Parameter | Description |
|---|
agent_id | The ID of the agent to dispatch |
Request Body#
| Field | Type | Required | Description |
|---|
query_source | string | ✅ Yes | Source of the voice call request (e.g., "web") |
history | array | ❌ No | Optional list of prior conversation turns |
chat_thread_id | number | ❌ No | Optional chat thread ID to continue an existing session |
Example Request#
POST /response-service/api/v2/agents/{agent_id}/voice-chat
Content-Type: application/json
{
"chat_thread_id": 1,
"history": [
{
"bot": "Hi there!",
"user": "Hello"
}
],
"query_source": "web"
}
Example Response#
{
"data": {
"chat_thread_id": 123,
"livekit_url": "wss://your-livekit-server.com",
"participant_token": "your-participant-token"
},
"message": "Successfully dispatched agent and generated participant token",
"success": true
}
What happens here?
The API dispatches your AI agent to a LiveKit room and returns everything your frontend needs to join the same room as a participant — the server URL and a pre-signed participant token.
Step 2 — Connect Your Frontend to LiveKit#
Once you have the livekit_url and participant_token from the API response, use them to connect your frontend to the LiveKit room.LiveKit provides open-source SDKs for all major platforms — JavaScript/React, Swift (iOS), Android, React Native, Flutter, and more.This page covers how to use the Room object to connect using your URL and token, handle participant events, publish/subscribe to audio tracks, and manage disconnection scenarios.
Step 3 — Build & Test Your Frontend#
LiveKit provides an open-source Agents Playground that serves as both a ready-made frontend and a testing tool. You can use it to verify your integration immediately, and fork it as the foundation for your own voice call UI.A ready-made React frontend that handles room connection, participant audio rendering, and session state management. Fork and adapt it to your use case.
Running the Playground Locally#
1. Clone the repository and install dependencies2. Start the development server
3. Open the playground in your browserNavigate to http://localhost:3000. You'll see the connection screen where you can enter your credentials. 4. Connect using your API credentialsCall the Generate Token API to get your livekit_url and participant_token, then:Paste the livekit_url into the wss://url field
Paste the participant_token into the room token field
What to expect
Once connected, the playground opens a live session view showing the Agent Audio visualizer and a Chat panel. Your agent will join the room automatically and you can start speaking with it in real time.
Need Help?#
If you encounter access issues or need assistance with the integration, contact the Ejento Support Team.