c.l.cladDocs

TypeScript reference

Key types and the full SupportChat interface available on the global API.

Type definitions for the global Support Chat API are available for TypeScript projects. The members below live on the global SupportChat object once the loader script has run. Key types:

// Exposed on the global, e.g. `SupportChat.createChat(...)`.
function createChat(options: CreateChatOptions): SupportChat;
const version: string;
 
// Exposed as `SupportChat.Error`.
class SupportChatError extends Error {
  code: SupportChatErrorCode;
  reason?: string;
  requestId?: string;
  recoverable: boolean;
}
 
interface SupportChat {
  boot(options?: BootOptions): Promise<void>;
  identify(options: IdentifyOptions): Promise<void>;
  update(options: UpdateOptions): Promise<void>;
  shutdown(options?: ShutdownOptions): Promise<void>;
  destroy(): Promise<void>;
 
  open(): Promise<void>;
  close(): Promise<void>;
  show(): void;
  hide(): void;
  showLauncher(): void;
  hideLauncher(): void;
  setLauncherVisible(visible: boolean): void;
 
  render(options: RenderOptions): Promise<void>;
 
  startConversation(options?: StartConversationOptions): Promise<Conversation>;
  showConversation(conversationId: string): Promise<void>;
  listConversations(options?: PaginationOptions): Promise<Page<Conversation>>;
  sendMessage(options: SendMessageOptions): Promise<Message>;
  markConversationRead(conversationId: string): Promise<void>;
  showNewMessage(options?: ShowNewMessageOptions): Promise<void>;
 
  searchArticles(query: string): Promise<Article[]>;
  showArticle(articleId: string): Promise<void>;
  showTicketForm(formId: string, options?: ShowTicketFormOptions): Promise<void>;
 
  setContext(context: Record<string, JsonValue>): void;
  setConversationTags(tags: string[]): void;
  setCustomFields(fields: Record<string, JsonValue>): void;
 
  setTheme(theme: ThemeConfig): void;
  setLocale(locale: string): void;
  setZIndex(zIndex: number): void;
  setCookieConsent(consent: CookieConsent): Promise<void>;
 
  on<E extends ChatEventName>(event: E, handler: ChatEventHandler<E>): () => void;
  off<E extends ChatEventName>(event: E, handler: ChatEventHandler<E>): void;
 
  readonly state: SdkState;
}

See the Support Chat .d.ts type definitions for the complete set (Conversation, Message, ThemeConfig, LauncherConfig, event payload maps, and more).