@onyxplatform/dialer-sdk
v0.0.7
Published
SDK for integrating with the Onyx Chrome Extension Dialer
Maintainers
Readme
@onyxplatform/dialer-sdk
TypeScript SDK that lets third-party CRMs communicate with the Onyx Chrome Extension Dialer.
Installation
npm install @onyxplatform/dialer-sdkBrowser Support
The SDK requires a Chrome browser. The user must have the Onyx Chrome Dialer installed prior for the SDK to work.
import { isBrowserSupported } from '@onyxplatform/dialer-sdk';
if (!isBrowserSupported()) {
// Show a message telling the user to switch to Chrome
}Getting Started
import { createOnyxSDK, isBrowserSupported } from '@onyxplatform/dialer-sdk';
if (!isBrowserSupported()) {
console.error('Onyx SDK requires a Chromium-based browser.');
} else {
const sdk = createOnyxSDK();
// Listen for new calls
sdk.onCallStarted((callState) => {
console.log('Call started:', callState.call.id, callState.call.direction);
console.log('Participants:', callState.participants);
});
// Clean up when done
window.addEventListener('beforeunload', () => {
sdk.destroy();
});
}createOnyxSDK(extensionId?: string): OnyxSDK
Factory function. Creates and returns an OnyxSDK instance connected to the extension. Call destroy() when done.
isBrowserSupported(): boolean
Returns true if the required Chrome extension APIs are available. Call this before createOnyxSDK().
onCallStarted(callback: CallStartedCallback): () => void
Convenience listener that fires when the user first connects to a call. The callback receives the initial CallState as its argument.
Returns an unsubscribe function.
const unsubscribe = sdk.onCallStarted((callState) => {
console.log('Direction:', callState.call.direction);
console.log('Status:', callState.call.status);
console.log('Participants:', callState.participants);
});
// Later:
unsubscribe();Types
CallState
interface CallState {
call: {
id: number;
direction: CallDirection;
status: CallStatus;
};
source?: CallSource;
campaign?: CallCampaign;
participants: Participant[];
}Participant
interface Participant {
type: ParticipantType;
label: string;
hold: boolean;
muted: boolean;
status: ParticipantStatus;
}CallSource
interface CallSource {
id: number;
name: string;
billingType: SourceBillingType;
billingCostDollars?: number;
billingDurationTimeSeconds?: number;
}CallCampaign
interface CallCampaign {
id: number;
name: string;
direction: CampaignDirection;
}Key Enums
| Enum | Values |
|------|--------|
| CallDirection | INBOUND, DIRECT_INBOUND, AUTO_OUTBOUND, MANUAL_OUTBOUND, OUTBOUND_CAMPAIGN_CALLBACK |
| CallStatus | RINGING, IN_PROGRESS, DISPOSITIONING |
| ParticipantType | AGENT, LEAD, EXTERNAL |
| ParticipantStatus | RINGING, IN_PROGRESS, COMPLETED |
