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.
Sending a Request
Request Message
To make a request, simply compose a Javascript object containing the command and arguments like below:Available Commands
| Command | Description | Parameters |
|---|---|---|
post.message | Send text message to Pria | inputs: [Array of strings] |
convo.start | Start speech-to-speech conversation | None |
convo.stop | Stop speech-to-speech conversation | None |
assistants.list | Get available assistants | None |
favorites.list | Get list of user’s favorites | None |
conversations.list | Get list of user’s conversations | None |
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.| Field | Type | Description |
|---|---|---|
type | String | Always "pria-response". This identifies the message as originating from Pria AI Middleware. |
response | Object | Contains the actual payload and control attributes for the message. |
response.content | Mixed | The content of the response—can be a String (error, status) or an Object (structured output). |
response.type | String | Indicates the type of content. "object" for JavaScript objects, "string" otherwise. |
response.isError | Boolean | true if the message represents an error, false otherwise. |
response.command | String | Indicates the command handled (e.g., post.message, convo.stop). |
version | Integer | The message version number for client compatibility management. |
"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.
| Subfield | Description |
|---|---|
content | The main body of the response. Can be a JavaScript object (structured data) or a string (simple message or error). |
type | Specifies the JavaScript type of content. Values are "object" (for JSON objects) or "string" (for plain text). |
isError | Boolean signaling error (true for errors, false for normal responses). |
command | String describing the executed command (e.g., post.message, convo.start, or convo.stop). |
Sample Responses
- Successful Message
- Error Response
- Conversation Control
See Object Definitions for a comple list of responses
Toggle visibility
Control the client UI visibility withWorking 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
| Issue | Solution |
|---|---|
| ”Connect Pria first” error | Ensure SDK is loaded and initialized |
| No responses received | Check if you’ve subscribed to responses |
| Unauthorized errors | Verify user authentication and permissions |
| Invalid JSON errors | Validate request format and structure |
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.