Advanced configurations

Quack AI Widget: Advanced Customization & JavaScript API Reference

This guide explains how to customize your Quack AI chat widget with CSS overrides and JavaScript APIs for advanced embedding, styling, and event handling.


1. CSS Customization

1.1 Widget Root Position

Override the default position of the chat widget:

.quackchat-root {
  bottom: 60px !important;
  right: 60px !important;
}
  • Adjusts the floating position of the chat widget.

  • Use !important to ensure your override takes priority.

💡 Pro Tip: You can use top and left instead, depending on your desired layout.


1.2 Custom Font Family

Override the chat widget’s font for seamless brand alignment:

.qc-themes {
  --qc-font-family: "Bytesized", sans-serif !important;
}
  • Sets a custom font family for all Quack AI chat widget text.

  • Use your own font or any web-safe font stack.


2. JavaScript API

2.1 Programmatically Open/Close the Chat

Trigger chat visibility using window.postMessage:

// Opens the chat
window.quack.expandChat()

// Closes the chat
window.quack.minimizeChat()
  • Useful for opening the chat after specific user actions or closing it programmatically.

  • Works across all major browsers with embedded widgets.


2.2 Identify Users in Session

Associate user information with the current chat session:

window.identify({
  email: "[email protected]",
  id: "123",
  // ...any other user fields
});
  • Call after user authentication or profile update.

  • Accepts any key-value pairs to enrich session context.


2.3 Track Custom Events

Integrate your own event tracking logic:

window.trackCallback(function(eventName, properties) {
  // Handle event data
});
  • Receives all trackable events from Quack AI (e.g., chat_opened, message_sent).

  • eventName: Name of the triggered event.

  • properties: Additional metadata for the event.


2.4 Add Custom Error Handling

Capture and manage widget errors in your application:

window.addErrorHandler(function(error) {
  // Custom error processing
});
  • Any uncaught errors from the widget will be passed to this handler.

  • Enables advanced logging, alerting, or UI fallback.


Example Integration

<!-- Example: Custom styling and JavaScript API usage -->
<style>
  .quackchat-root { bottom: 60px !important; right: 60px !important; }
  .qc-themes { --qc-font-family: "Bytesized", sans-serif !important; }
</style>
<script>
  window.identify({ email: "[email protected]", id: "abc-456" });
  window.trackCallback((event, props) => console.log(event, props));
  window.addErrorHandler(error => console.error('Quack Error:', error));
</script>

Last updated

Was this helpful?