Integration Methods

There are two primary ways to integrate Pria into your application:

Embed Integration

Installation

Install Pria on your website using the custom SDK:
<script src="https://pria.praxislxp.com/pria-sdk-web.js"></script>
For Canvas LMS integration, follow the Custom Theme Canvas Install Guide

Configuration Options

Configure Pria’s display behavior using the displayOptions object:
var displayOptions = {
    fullScreen: false,              // Expand in full screen mode
    openOnLoad: false,              // Open Pria immediately when loaded
    buttonWidth: '80px',            // Size of the Pria logo button
    buttonPosition: 'fixed',        // Button position type (fixed, relative, sticky)
    buttonPositionRight: '20px',    // Distance from right edge
    buttonPositionBottom: '20px',   // Distance from bottom edge
    buttonNoBounce: true,           // Disable button bounce animation
    priaContainerId: '',            // Container ID for Pria window (default: BODY)
    buttonContainerId: '',          // Container ID for button (default: BODY)
    allowPop: false,                // Allow popping out of containing iframe
    noUI: false                     // Disable UI for headless operation
}
Set noUI: true to use Pria programmatically without the visual interface

SDK Playground

Test your integration using the SDK Playground.

JavaScript API

Global Window Object

Once loaded, Pria is available as a global window object with the following methods:
const pria = {
    load: priasdk,              // Initialize Pria SDK
    send: priaSend,             // Send requests to Pria
    subscribe: priaSubscribe,   // Subscribe to responses
    unsubscribe: priaUnsubscribe, // Unsubscribe from responses
    setVisible: priaSetVisible, // Control UI visibility
    version: 1                  // SDK version
}

Available Commands

CommandDescriptionParameters
post.messageSend text message to PriaArray of strings
convo.startStart speech-to-speech conversationNone
convo.stopStop speech-to-speech conversationNone
assistants.listGet available assistantsNone

Sending Requests

Basic Message Request

Send a text message to your digital twin:
const request = {
    command: 'post.message',
    inputs: ['How are you?', 'Today is my birthday!']
}

pria.send(request)

Conversation Mode

Start speech-to-speech conversation:
const request = {
    command: 'convo.start'
}

pria.send(request)
Stop conversation mode:
const request = {
    command: 'convo.stop'
}

pria.send(request)

Error Handling

The pria.send() function may throw these errors:
  • “Connect Pria first, then retry” - Pria is not properly initialized
  • “Function requires valid JSON” - Invalid request format

Receiving Responses

Subscribe to Responses

To receive responses from Pria, you must first subscribe:
const handlePriaResponse = (response) => {
    console.log('Received from Pria:', response)
    // Process the response here
}

pria.subscribe(handlePriaResponse)

Response Format

All responses follow this structure:
{
    "type": "pria-response",
    "response": {
        "command": "post.message",
        "content": {
            "success": true,
            "outputs": ["Response text here"],
            "usage": 12048,
            "query_duration_ms": 9404,
            "model": "us.anthropic.claude-3-5-sonnet-20240620-v1:0"
        },
        "isError": false,
        "type": "object"
    },
    "version": 1
}

Response Examples

{
    "type": "pria-response",
    "response": {
        "command": "post.message",
        "content": {
            "success": true,
            "outputs": ["I am doing great! Happy birthday by the way.."],
            "usage": 12048,
            "query_duration_ms": 9404,
            "model": "us.anthropic.claude-3-5-sonnet-20240620-v1:0"
        },
        "isError": false,
        "type": "object"
    },
    "version": 1
}

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.

Usage Metrics

The usage property in responses indicates the total number of tokens consumed (input + output) for billing and monitoring purposes.

Best Practices

Error Handling

const sendMessage = async (message) => {
    try {
        const request = {
            command: 'post.message',
            inputs: [message]
        }
        
        pria.send(request)
    } catch (error) {
        console.error('Failed to send message:', error)
        // Handle error appropriately
    }
}

Response Processing

const handleResponse = (response) => {
    if (response.response.isError) {
        console.error('Pria error:', response.response.content)
        return
    }
    
    // Process successful response
    const outputs = response.response.content.outputs
    outputs.forEach(output => {
        // Display or process each output
        console.log(output)
    })
}

Cleanup

// Unsubscribe when component unmounts or page unloads
window.addEventListener('beforeunload', () => {
    pria.unsubscribe(handleResponse)
})

Troubleshooting

Common Issues

IssueSolution
”Connect Pria first” errorEnsure SDK is loaded and initialized
No responses receivedCheck if you’ve subscribed to responses
Unauthorized errorsVerify user authentication and permissions
Invalid JSON errorsValidate request format and structure

Debug Mode

Enable debug logging to troubleshoot integration issues:
// Add to your configuration
var displayOptions = {
    // ... other options
    debug: true  // Enable debug logging
}

Support

For additional help with integration: