Technical Specifications
Overview
The Optave Assistant for Salesforce integrates AI capabilities into Salesforce through Lightning Web Components (LWC). The solution establishes a connection between the Salesforce Service Console and Optave's AI services via secure API integrations and WebSocket connections. The architecture follows a modular design where components communicate through Lightning Message Service and shared WebSocket connections. The lightweight LWC components work together to provide a seamless AI assistant experience.
Technologies Used
- Lightning Web Components (LWC): Modern framework for building Salesforce components
- Lightning Message Service: Communication mechanism between LWC components
- Platform Utility Bar API: Manages utility panel behavior and interactions
- Apex: Server-side language for custom business logic in Salesforce
- Named Credentials: Secure storage for authentication credentials
- Custom Metadata Types: Configuration storage for environment-specific settings
- Optave JavaScript SDK: Powers communication between Salesforce and Optave AI services
- JWT Authentication: Secure token-based authentication for API calls
- ChartJS: Visualization library for displaying metrics and analytics
Project Structure
├── OCOClient
│ ├── .husky/
| |── .vscode/
| |── config/
| |── force-app/
| | └── main/default/
| | ├── lwc/
| | ├── classes/
| | ├── messageChannels/
| | └── staticresources/
| |── scripts/
│ ├── .eslintignore
│ ├── .forceignore
│ ├── .prettierignore
│ ├── jest.config.js
│ ├── package.json
│ ├── sfdx-project.json
├── README.md
├── contributing.md
└── .gitignore
Directory Structure
The Optave Assistant for Salesforce follows a structured organization of files and directories:
Configuration
/config/- Salesforce DX configuration files including project-scratch-def.json for defining scratch org development environments
Application Code
/force-app/main/default/- Primary application components:-
/classes/- Apex classes for server-side logic:- NamedCredentials.cls - Manages authentication to external APIs and services, handling credentials securely
- OCOSecretController.cls - Handles access to custom metadata configuration
-
/lwc/- Lightning Web Components:- agentUI - Primary agent interface bringing together customer data, conversation management, and AI-powered suggestions
- helpers/optaveAssistant.js - Core functionality that coordinates communication with Salesforce's Conversation Toolkit API and Optave services
- adjustModal - Provides a modal interface for users to request fine-tuning or content adjustments to optimize AI-generated responses
- elevateModal - Offers a modal interface for reviewing and escalating AI-generated replies for further quality control or intervention
- feedback - Collects and displays quality feedback for AI-generated replies with scoring across multiple criteria (empathy, responsiveness, effectiveness, etc.)
- insights - Real-time display of customer analytics, sentiment analysis, and conversation metrics
- lightningFooter - Sophisticated footer component with multiple configurable sections
- loadingBar - Visual progress indicator for data loading
- settings - Configuration interface for controlling AI behavior, language settings, and response options, integrated with platformUtilityBarApi for utility panel management
- sourceModal - Display of information sources with attribution and confidence ratings
- sources - Manages and displays reference content and citations used by the AI to generate responses, supports filtering and highlighting of relevant content
- translation - Provides real-time language detection and translation capabilities for operator-customer interactions
- agentUI - Primary agent interface bringing together customer data, conversation management, and AI-powered suggestions
-
/messageChannels/- Lightning Message Service channels:- SettingsUpdateChannel - Facilitates communication between components for settings updates
-
/staticresources/- External libraries and assets:- Chart.js - JavaScript charting library for data visualization dashboards
- OptaveJavascriptSDK.js - Core client-side SDK providing Optave platform functionality
- UI Assets - Various images, icons, and visual elements including sentiment indicators and action buttons
-
Testing
/force-app/test/jest-mocks/- Mock implementations for component testing
Utilities
/scripts/- Development and maintenance utilities:/apex/- Apex development scripts/soql/- Database query scripts
Key Configuration Files
-
/jest.config.js- Configuration for Jest testing framework, defining test patterns and mock implementations. -
/lwc.config.json- Lightning Web Component configuration. -
/package.json- NPM configuration defining project dependencies, scripts, and metadata. -
/sfdx-project.json- Salesforce DX project configuration defining package directories and settings.
Component Structure
Lightning Web Components (LWC) follow a standard structure:
- /tests/ - Jest test files
- .html - Component markup
- .js - Component JavaScript logic
- .css - Component styling
- .js-meta.xml - Component metadata and configuration
- helpers/ - Optional directory containing helper files for complex components (e.g., agentUI/helpers)
SDK Connection
The Optave JavaScript SDK establishes a secure connection between Salesforce and Optave AI services. It manages secure sessions, handles errors gracefully, and implements automatic reconnection policies to ensure continuous functionality.
Note: The secure connection is initiated by the agentUI component in the Lightning Web Components. Credentials for the SDK connection are retrieved from Apex classes such as NamedCredentials.cls and OCOSecretController.cls.
Component Communication
- Lightning Message Service (LMS): Primary method for component communication
- SettingsUpdateChannel: Broadcasts configuration changes to all subscribed components
- LWC Event System: Built-in JavaScript custom events for parent-child component communication
- Conversation Toolkit API: Integrated with
optaveAssistant.jsto manage Salesforce Service Console conversations - Platform Utility Bar API:
- EnclosingUtilityId: Used to identify the utility panel containing the settings component
- minimize: Provides programmatic control of the utility panel state (used in settings component)
- Apex Controllers: Server-side operations for data access and authentication
- WebSockets: Real-time updates from Optave AI services