The Window API provides a direct, Promise-based TypeScript API exposed onDocumentation Index
Fetch the complete documentation index at: https://docs.corti.ai/llms.txt
Use this file to discover all available pages before exploring further.
window.CortiEmbedded for integration with Corti Assistant. This method is suitable for same-origin integrations requiring direct JavaScript access.
Web Component API is recommended for most cases. The Web Component API is recommended when you embed the Assistant via a local host page. The Window API remains useful for specific scenarios, such as embedding via direct URL in webviews/iframes. It is fully supported and not deprecated.
Web Component has full working examples. Complete, runnable examples are available for the Web Component integration method, which is the recommended approach for most integrations. Window API examples for same-origin scenarios will be added to the repository in the future.
Overview
The Window API offers a Promise-based, TypeScript-friendly interface for integrating Corti Assistant into your application. It provides direct access towindow.CortiEmbedded.v1, making it feel like a traditional JavaScript SDK.
Requirements
Implementation requirements
To use the Window API, you’ll need to implement a WebView or similar browser component within your native application. The embedded Corti Assistant runs as a web application and requires a modern browser environment to function properly.Minimum requirements
- Modern WebView: Use a modern WebView implementation that supports:
- WebView2 (Windows) - Recommended for Windows applications
- WKWebView (iOS/macOS) - Recommended for Apple platforms
- WebView (Android) - Use the latest Chromium-based WebView
- Electron WebView - For Electron-based applications
- Browser compatibility: The WebView must support:
- ES6+ JavaScript features
- Modern Web APIs (WebRTC, MediaDevices API)
- PostMessage API
- Local Storage and Session Storage
- Microphone permissions: Your application must request and handle microphone permissions:
- Request microphone access before initializing the embedded Assistant
- Handle permission denial gracefully
- Provide clear messaging to users about why microphone access is needed
- Ensure permissions are granted at the OS level (not just browser level)
Platform-specific considerations
Windows (WebView2)- Ensure WebView2 Runtime is installed or bundled with your application
- Request microphone permissions in your application manifest
- Handle permission prompts appropriately
- Add
NSMicrophoneUsageDescriptionto your Info.plist - Request microphone permissions using
AVAudioSessionor similar APIs - Ensure permissions are granted before loading the embedded Assistant
- Request
RECORD_AUDIOpermission in your AndroidManifest.xml - Request runtime permissions using
ActivityCompat.requestPermissions() - Handle permission callbacks appropriately
Recommendations
- Use TypeScript for better type safety and developer experience
- Implement proper error handling for all API calls
- Handle token refresh to maintain user sessions
- Request microphone permissions early in your application flow
- Test on target platforms to ensure WebView compatibility
Quick Start
Step 1: Set up authentication
Before using the Window API, authenticate your users using OAuth2. See the Authentication Guide for complete setup instructions including Authorization Code Flow with PKCE (recommended), obtaining tokens, and handling token refresh.All Embedded Assistant integrations require user-based OAuth2 authentication. Client credentials and machine-to-machine flows are not supported.
- Handle token refresh to maintain sessions
- Never expose client secrets in client-side code
Step 2: Wait for the Embedded App to be ready
The embedded Corti Assistant will send anembedded.ready event when it’s loaded and ready to receive API calls:
Basic Setup
Step 3: Authenticate the user
Once the API is ready, authenticate the user with their OAuth2 tokens:Authentication
Step 4: Configure and use
After authentication, you can configure the interface and start using the Assistant:Configure and Use
API structure
The API is available atwindow.CortiEmbedded.v1 and provides the following methods:
Same API as Web Component
The Window API provides the exact same methods as described in the API Reference. The only difference is the invocation style - with Window API, you call methods directly viawindow.CortiEmbedded.v1.methodName() instead of through a Web Component.
Example:
- Web Component:
await api.auth({ ... }) - Window API:
await window.CortiEmbedded.v1.auth({ ... })
Events
Corti Assistant dispatches events to notify your application of user activity, state change, data updates, and many more interactions. When using the Window API, events are delivered through the samepostMessage mechanism.
Event format translation
Core events documented in the Events Reference are wrapped in theCORTI_EMBEDDED_EVENT message type:
Core event structure:
Listening for events
Even when using the Window API for method calls, events are delivered viapostMessage. Set up a listener:
Listening for Events
Combining API calls and events
Use the Window API for actions and events for state updates:Combined Usage
Available events
For a complete list of events and their payload structures, see the Events Overview. Common events include:recording.started- Recording has startedrecording.paused- Recording has pauseddocument.generated- Document has been generateddocument.updated- Document has been editedinteraction.loaded- Interaction has been loadederror.triggered- An error occurred
Legacy events
The embedded Assistant also dispatches legacy events using camelCase names (e.g.,
recordingStarted, documentGenerated). These are deprecated and will be removed in a future version.Error handling
All API methods return Promises and can throw errors. Always wrap calls in try-catch blocks:Error Handling
TypeScript support
If you’re using TypeScript, you can extend the Window interface to get type safety:TypeScript Definitions
Helper function
You can create a helper function to ensure the API is ready:Helper Function
Next steps
- Review the OAuth Authentication Guide to set up user authentication
- See the API Reference for all available methods and their parameters
- Learn about events that the embedded app can send
- Check out the PostMessage API for cross-origin integrations
Please contact us for help or questions.