Skip to main content

Introduction

The Widget WebView endpoint is an interactive HTML wrapper that allows you to embed the Lovi chat widget securely within web pages or mobile applications. Instead of returning a standard JSON response, this endpoint serves a complete HTML document containing an iframe pointing to the chat interface. This wrapper acts as a secure bridge, fetching the necessary integration metadata (such as the agent’s welcome message and language settings) on the server side and securely injecting it into the web view using standard postMessage communication.

🌐 Get Widget WebView

Method: GET Format: HTML

Endpoint

Alternative Path format: GET https://cloud.lovi.ai/functions/v1/widgetWebView/{customer_id}/{widget_id}

Query Parameters

If you are not using the path structure mentioned above, you must pass the required parameters in the query string.

How It Works

  1. Authentication: The server validates the customer_id (Access Key) and verifies ownership of the widget_id.
  2. Metadata Fetching: It retrieves the widget configuration and optionally queries the Lovi translation backend to translate the agent’s welcome message into the requested lang.
  3. HTML Delivery: The server returns an HTML page containing an <iframe src="https://widget.lovi.ai/?cw_id=...">.
  4. PostMessage Bridge: The loaded HTML contains JavaScript that listens for get_widget and get_customer events triggered by the iframe. It securely responds with the widget’s configuration (widgetData) and handles local storage (such as generating a unique user ID).

Common Errors

If the widget fails to load, you might receive one of the following HTTP status codes instead of the HTML payload:
  • 400 Bad Request: Missing customer_id or widget_id, or the widget_id is not a valid UUID.
  • 403 Forbidden: Invalid customer_id (Access Key validation failed).
  • 404 Not Found: The company or the specified widget could not be found.
  • 500 Internal Server Error: An unexpected error occurred while generating the wrapper.
🧭 Important: If the widget appears stuck on a “Loading Widget…” screen, check your browser’s console. Ensure that your environment allows cross-origin iframes and does not block postMessage communication between the WebView and widget.lovi.ai.
This endpoint embeds text chat. For a spoken call in the browser, see the voice widget.