Web SDK
Integrate Millis AI’s voice agent capabilities directly into your web applications and browser extensions.
Last updated
Integrate Millis AI’s voice agent capabilities directly into your web applications and browser extensions.
Last updated
Install the SDK with npm:
Here’s how to quickly set up a voice agent in your web application:
Obtain your public key from your
Learn more about which endPoint
to use .
Starting from version 1.0.15, use the following format to initiate a call:
Replace agent-id
with the ID of your agent obtained from the Playground.
The metadata
is optional. You can pass any additional data to the session, which we will forward to your custom LLM and function webhooks. If you provide metadata
, you can make it available to the agent by setting include_metadata_in_prompt
to true
. This will include the metadata in the agent’s system prompt, allowing the agent to use the data during the conversation.
You can also dynamically create a temporary voice agent with custom configurations using the code below:
When both agent_id
and agent_config
are provided, the session will use the configuration associated with agent_id
but will override it with any settings provided in agent_config
. This option allows for minor modifications to the agent’s default configuration on a per-session basis.
Metadata
metadata
: Optional field to pass any additional information that may personalize the conversation. It can be used by the agent if include_metadata_in_prompt
is set to true
.
Including Metadata in Prompt
include_metadata_in_prompt
: Boolean flag (true
or false
). If true
, the metadata provided will be included in the prompt to give context to the agent.
Session Continuation
session_continuation
: Provide session_id
from a previous session to enable continuity in conversation. This allows the agent to reference previous interactions.
Description: Emitted when the WebSocket connection is successfully opened.
Callback Signature:
Description: Emitted when the client is ready to start processing audio or other tasks.
Callback Signature:
Description: Emitted when a session has ended.
Callback Signature:
Description: Emitted when audio data is received.
Callback Signature:
Parameters:
audio
- The received audio data in Uint8Array
format.
Description: Emitted when agent’s response text is received.
Callback Signature:
Parameters:
text
- The received response text.
payload
- An object containing additional information.
is_final
(optional) - A boolean indicating if the response text is final.
Description: Emitted when user’s transcript text is received.
Callback Signature:
Parameters:
text
- The received transcript text.
payload
- An object containing additional information.
is_final
(optional) - A boolean indicating if the transcript text is final.
Description: Emitted when agent triggered a function call.
Callback Signature:
Parameters:
text
- Empty.
payload
- Information about the triggered function.
name
- The function name.
params
- The params being used in the function call.
Description: Emitted with an AnalyserNode
for agent’s audio analysis.
Callback Signature:
Parameters:
analyzer
- The AnalyserNode
used for audio analysis.
Description: Emitted when user audio is ready for processing.
Callback Signature:
Parameters:
data
- An object containing audio-related information.
analyser
- The AnalyserNode
for user’s audio analysis.
stream
- The MediaStream
containing the user’s audio data.
Description: Emitted to report latency information for debugging purpose.
Callback Signature:
Parameters:
latency
- The measured latency in milliseconds.
Description: Emitted when the WebSocket connection is closed.
Callback Signature:
Parameters:
event
- The CloseEvent
containing details about the WebSocket closure.
Description: Emitted when an error occurs in the WebSocket connection.
Callback Signature:
Parameters:
error
- The Event
containing details about the error.
Here’s an example of how to listen to these events in the Client
class:
Using a Predefined Agent
First, create a voice agent from the . Then, start a conversation with your agent using the following code:
Dynamically Creating a Temporary Voice Agent
To obtain the voice_id, use this API to acquire the complete list of voices:
Overriding Agent configuration
Additional Parameters
If you encounter any issues or have questions, please reach out to us directly at .