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 aniframe 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
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
- Authentication: The server validates the
customer_id(Access Key) and verifies ownership of thewidget_id. - 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. - HTML Delivery: The server returns an HTML page containing an
<iframe src="https://widget.lovi.ai/?cw_id=...">. - PostMessage Bridge: The loaded HTML contains JavaScript that listens for
get_widgetandget_customerevents 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_idorwidget_id, or thewidget_idis 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 blockThis endpoint embeds text chat. For a spoken call in the browser, see the voice widget.postMessagecommunication between the WebView andwidget.lovi.ai.
