Client SDK
The JavaScript SDK is available as soon as you integrate your application with either the Web SDK or via Canvas Theme. It enables client-side automation with your Digital Twin—such as sending messages, listing favorites, and running assistant instructions.Integration Options
Integrate your Digital Twin in one of these ways to access the SDK:- Web SDK: Embed the Digital Twin directly in your web app by installing the Web SDK for easy setup, user management, and customization.
- Canvas Theme: Inject the Digital Twin into Canvas using the Theme for direct access to SDK features within the Canvas LMS.
Global Window Object
When your Digital Twin is integrated, thepria object is injected directly onto the global window (DOM), making it the central access point for all Pria SDK API calls from anywhere in your application. This allows you to easily interact with Pria’s messaging, UI control, and event management methods without additional imports or setup—simply reference window.pria.
By being attached to the DOM, pria acts as your always-available gateway for secure and seamless integration with all Pria interfaces and backend services—enabling features like messaging, automation, and UI control from any context in your client-side code.
Messaging Technology
Communication between your web application and the Praxis AI Middleware via the Web SDK is powered by browser messaging, which securely enables cross-origin interactions between window objects, such as between a main application and an embedded iframe or pop-up. Requests are sent to the backend middleware server using thepria.send() API method, ensuring safe and reliable message delivery for seamless integration and robust application workflows.
Voice (Convo Mode) in Embedded Contexts
When your Digital Twin uses voice conversations (Convo Mode) inside an iframe you control — including LMS embeds such as Canvas — the host page’s iframe must delegate microphone and audio permissions, or the browser will hard-block voice regardless of what the user allows:convoMode in displayOptions) and explicit convo.start / convo.stop commands keep priority over that instance-level setting.
Sending a Request
Request Message
To make a request, simply compose a Javascript object containing the command and arguments like below:Available Commands
Sample Requests
- Post Message
- Conversation Mode
- List
Send a text message to your digital twin:
Error Handling
Thepria.send() function may throw these errors:
Receiving Responses
Subscribe to Responses
To receive responses from Pria, you must first subscribe:Response Message
A response message from the Pria AI Middleware follows a clear and structured format to ensure consistent integration and robust client parsing. Each response includes standard fields that define its source, content, format, and compatibility.
type
The literal string constant
"pria-response". Use as a filter or discriminator in your message handling logic.
response
Top-level object that wraps all core response details from Pria AI Middleware.
version
Integer value indicating the version of the response structure. Used for ensuring compatibility with various client parsers.
Sample Responses
- Successful Message
- Error Response
- Conversation Control
See Object Definitions for a complete list of responses
UI Control Methods
The SDK provides several methods to control Pria’s visibility and display state.Visibility Control
Control whether Pria is visible on the page at all. When hidden, both the button and UI panel are completely removed from view.Display Control
Control whether the Pria UI panel is expanded or collapsed to the button.Ready State
Check if Pria is fully initialized and ready to receive commands before sending messages:Convo Ready State
After the user authenticates, the Digital Twin sends aconvo.ready event to the SDK indicating whether real-time voice (speech-to-speech) mode is authorized for the current user. The SDK captures this and exposes it via isConvoReady().
isConvoReady() returns false until the Digital Twin sends the convo.ready event after login. This happens automatically — you do not need to request it.convo.ready event:
The convo.ready event is a proactive notification sent by the Digital Twin after the user logs in. It tells the embedding application whether real-time voice is available. You can listen for this event via pria.subscribe():
Cleanup and Destroy
Properly destroy and remove Pria when no longer needed:destroy() method performs complete cleanup:
- Removes all UI elements (iframe, button, containers)
- Removes injected CSS and OAuth scripts
- Cleans up all event listeners (keyboard shortcuts, drag handlers, message handlers)
- Clears internal state and subscriber callbacks
- Removes
window.priaandwindow.priasdkreferences
PriaIntegration), use these methods for clean lifecycle management:
UI Control Reference
Working with the SDK
Authentication & Security
The SDK uses the identity of the user currently connected to the digital twin. Ensure proper authentication is in place before making requests.
Requirements
- Pria must be properly configured and fully connected
- User must be authenticated with appropriate permissions
- Valid session must be established
Content Format
Pria outputs content in Markdown format. Parse responses accordingly in your application.
Error Handling
It is best practices to wrap function calls in a try/catch block to avoid unhandled exceptionsResponse Processing
It is best practive to handle responses from Pria by looking at response message type, isError, command, etc to handle responses for all situationsCleanup
Consider removing the event handlers you have declared when subscribing to receive response messages before your application terminatesTroubleshooting
Common Issues
Debug Mode
Enable debug logging to troubleshoot integration issues:SDK Playground Example
You can take a look at a running example at SDK Playground Example.