Type Reference#
TypeScript
interface ChatboxConfig {
apiKey: string;
container?: HTMLElement;
}
interface BubbleConfig {
apiKey: string;
position?: 'bottom-right' | 'bottom-left';
bubbleColor?: string;
bubbleSize?: number;
bubbleIcon?: string;
bubbleIconSize?: number;
offset?: {
bottom?: number;
right?: number;
left?: number;
};
}
interface IdentifyPayload {
/** Host-signed identity token; null signs the visitor out. */
identityToken?: string | null;
/** Leave unset — never a user id, email or anything guessable. */
visitorId?: string;
name?: string;
email?: string;
phone?: string;
company?: string;
latitude?: number;
longitude?: number;
}
/** Returns the signed-in user's token, or null for a guest. Throw on errors. */
type IdentityTokenProvider = () =>
| Promise<string | null | undefined>
| string
| null
| undefined;
interface GydrAPI {
chatbox(config: ChatboxConfig): ChatboxInstance;
bubble(config: BubbleConfig): BubbleInstance;
identify(payload: IdentifyPayload): void;
setIdentityTokenProvider(provider: IdentityTokenProvider | null): void;
reset(): void;
}
interface ChatboxInstance {
destroy(): void;
}
interface BubbleInstance {
open(): void;
close(): void;
toggle(): void;
destroy(): void;
readonly isOpen: boolean;
}