To integrate LiveChat with Lovable, create a LiveChat Developer App to get a Personal Access Token, store it in Cloud → Secrets, then build Edge Functions that call the LiveChat REST API for chats, agents, customers, and chat archives. LiveChat is the ideal choice when you need a focused real-time chat widget embedded in your Lovable app without the broader scope of Intercom or Zendesk.
Add real-time customer chat and analytics to Lovable with LiveChat's API
LiveChat is purpose-built for one thing: real-time chat between businesses and their customers. Unlike Intercom (which combines messaging, help center, chatbots, and CRM) or Zendesk (which leads with ticketing), LiveChat keeps its focus narrow — a polished chat widget, agent management tools, and chat analytics. For Lovable apps where the primary support channel is live chat rather than tickets or async messaging, LiveChat offers a simpler and more cost-effective integration path.
LiveChat's integration has two components: the widget (a JavaScript-based chat bubble embedded in your frontend) and the REST API (accessed via Edge Functions for analytics, chat management, and customer data). The widget handles real-time chat natively, while the API enables you to build custom dashboards showing chat volume, response times, agent availability, and conversation archives.
Authentication for the LiveChat REST API uses Personal Access Tokens generated in the LiveChat Developer Console. These tokens provide API access scoped to your account permissions. The API base URL is https://api.livechatinc.com/ and the current stable version is v3.6.
The most common Lovable + LiveChat integration patterns are: embedding the chat widget with user identity pre-filled from your app's authenticated session, building internal dashboards showing chat queue status and agent metrics, and fetching chat archives to store conversation history in your Supabase database for compliance or review purposes.
Integration method
LiveChat has no native Lovable connector. Chat operations and analytics are proxied through Lovable Edge Functions that call the LiveChat REST API v3.6 using Bearer token authentication. A Personal Access Token from the LiveChat Developer Console is stored in Cloud → Secrets and accessed via Deno.env.get(), keeping credentials server-side and preventing CORS issues from direct browser calls.
Prerequisites
- A Lovable project with Lovable Cloud enabled (Edge Functions require a deployed app)
- A LiveChat account (14-day free trial available at livechat.com — the Starter plan at $20/agent/month is the minimum paid tier)
- Access to the LiveChat Developer Console at developers.livechat.com to create an application
- Your LiveChat License Number (visible in LiveChat settings — required for widget initialization)
Step-by-step guide
Create a LiveChat Developer App and get a Personal Access Token
Create a LiveChat Developer App and get a Personal Access Token
LiveChat API authentication uses Personal Access Tokens generated through the LiveChat Developer Console. Go to developers.livechat.com and sign in with your LiveChat account. Click 'Create new app' in the top right. Give the app a name like 'Lovable Integration' and select 'Service account credentials' as the app type — this is appropriate for server-side Edge Function integrations. In the app's Authorization section, you will find the Client ID and Client Secret. However, for Lovable Edge Functions, a Personal Access Token is simpler. To generate one: go to developers.livechat.com → Your Apps → Build → Personal Access Tokens. Click 'Generate a new token'. Select the scopes you need: - chats--all:read — for reading chat archives and summaries - reports_read — for accessing analytics and reports - agents--all:read — for fetching agent information - customers:read — for accessing customer profiles Generate the token. Copy the token string — it starts with 'Bearer dal:...' or similar. This is your Personal Access Token for API calls. Also note your LiveChat License Number — found in LiveChat settings at my.livechatinc.com → Settings → Chat Widget → under 'LiveChat for developers', or visible in your LiveChat URL. The license number is a 5-8 digit number like '12345678'. You need it both for widget initialization and as the account ID for some API calls. For the chat widget on your Lovable frontend, you need the License Number (not the API token — the License Number is a public identifier safe for client-side code).
Pro tip: The LiveChat License Number is a public identifier used for widget initialization — it is safe to include in frontend code as VITE_LIVECHAT_LICENSE_ID. Do not confuse it with the API access token, which must stay server-side in Cloud → Secrets.
Expected result: A LiveChat Developer App is created. A Personal Access Token with required scopes is generated and copied. The LiveChat License Number is noted. Both are ready to be stored appropriately (token in Cloud → Secrets, License Number as an env variable).
Store credentials in Cloud Secrets and add the chat widget to Lovable
Store credentials in Cloud Secrets and add the chat widget to Lovable
Add LiveChat API credentials to Lovable's Cloud Secrets panel. In Lovable, click '+' → Cloud panel → Secrets. Add two secrets: - LIVECHAT_ACCESS_TOKEN — your Personal Access Token from the Developer Console - LIVECHAT_ACCOUNT_ID — your LiveChat License Number (also used as account ID in API calls) For the widget (frontend), you also need the License Number as a build-time environment variable. In Lovable, this should be set as VITE_LIVECHAT_LICENSE_ID in your app's environment configuration — it is public and safe for the browser bundle. The LiveChat widget is a JavaScript snippet that initializes in the browser. The simplest implementation for React is to load the LiveChat script in your app's main component and initialize it with the license number. When a user is logged in, use the LiveChat JavaScript API to set their name and email: window.LiveChatWidget.call('set_customer_name', name) and window.LiveChatWidget.call('set_customer_email', email). LiveChat's JavaScript widget API also supports custom variables for passing plan tier, user ID, or any metadata to agents: window.LiveChatWidget.call('set_session_variables', { plan: 'pro', userId: user.id }). The LiveChat REST API base URL is https://api.livechatinc.com/ with version prefix v3.6 for most endpoints.
Add the LiveChat chat widget to my Lovable app. Load the LiveChat script asynchronously using the VITE_LIVECHAT_LICENSE_ID environment variable. When a user is logged in via Supabase Auth, call window.LiveChatWidget.call('set_customer_email', email) and window.LiveChatWidget.call('set_customer_name', name) to pre-fill their identity. Show the widget on all pages.
Paste this in Lovable chat
1// src/components/LiveChatWidget.tsx2import { useEffect } from 'react'3import { useAuth } from '@/hooks/useAuth'45declare global {6 interface Window {7 LiveChatWidget: {8 call: (method: string, ...args: unknown[]) => void9 on: (event: string, callback: (data: unknown) => void) => void10 }11 __lc: { license: number; asyncInit: boolean }12 }13}1415export function LiveChatWidget() {16 const { user } = useAuth()17 const licenseId = import.meta.env.VITE_LIVECHAT_LICENSE_ID1819 useEffect(() => {20 if (!licenseId) return2122 window.__lc = window.__lc || {}23 window.__lc.license = parseInt(licenseId)24 window.__lc.asyncInit = true2526 const script = document.createElement('script')27 script.async = true28 script.src = 'https://cdn.livechatinc.com/tracking.js'29 document.head.appendChild(script)3031 return () => {32 document.head.removeChild(script)33 }34 }, [licenseId])3536 useEffect(() => {37 if (!window.LiveChatWidget || !user) return38 window.LiveChatWidget.call('set_customer_email', user.email || '')39 window.LiveChatWidget.call('set_customer_name', user.user_metadata?.full_name || user.email || '')40 window.LiveChatWidget.call('set_session_variables', {41 user_id: user.id,42 })43 }, [user])4445 return null46}Pro tip: Add <LiveChatWidget /> to your App.tsx at the root level so it loads on every page. The widget automatically hides and shows based on your LiveChat availability settings without any additional code.
Expected result: The LiveChat chat bubble appears in the bottom-right corner of your deployed Lovable app. Logged-in users have their name and email pre-filled when starting a chat, visible to agents in the LiveChat agent workspace.
Create the LiveChat REST API proxy Edge Function
Create the LiveChat REST API proxy Edge Function
Build the Edge Function that queries LiveChat's REST API for analytics, chat archives, and agent data. These operations require the access token and cannot be performed from the browser. LiveChat REST API v3.6 key endpoints: - GET /v3.6/configuration/agents — list all agents with availability status - GET /v3.6/reports/chats/total_chats — total chat count for a date range - GET /v3.6/reports/chats/agents — per-agent chat statistics - GET /v3.6/reports/chats/first_response_time — average response time - GET /v3.6/reports/ratings/chats_count — satisfaction ratings count - GET /v3.6/chats — list chat summaries (archives) - GET /v3.6/chats/{chat_id} — get full chat transcript Authentication: Bearer token in the Authorization header plus the X-Region header if your account is in the European data center (dal.eu region). Most accounts are in the default US region. Date parameters in LiveChat analytics endpoints use ISO 8601 format: from and to parameters as YYYY-MM-DDThh:mm:ssZ. The reports are paginated with page parameter starting at 1. The chat archive (GET /v3.6/chats) returns chat summaries with ID, timestamps, agent, and ratings. To get the full message transcript, call GET /v3.6/chats/{chatId} with the specific chat ID.
Create an Edge Function called livechat-api at supabase/functions/livechat-api/index.ts. Accept POST with { action, params }. Support actions: list_agents, get_chat_stats, list_chat_archives, get_chat_transcript. Use LIVECHAT_ACCESS_TOKEN as Bearer and LIVECHAT_ACCOUNT_ID for account-scoped requests. Base URL: https://api.livechatinc.com/v3.6. Include CORS headers.
Paste this in Lovable chat
1import { serve } from 'https://deno.land/std@0.168.0/http/server.ts'23const corsHeaders = {4 'Access-Control-Allow-Origin': '*',5 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',6}78const LC_BASE = 'https://api.livechatinc.com/v3.6'910function livechatHeaders() {11 const token = Deno.env.get('LIVECHAT_ACCESS_TOKEN')12 if (!token) throw new Error('LIVECHAT_ACCESS_TOKEN not configured')13 return {14 Authorization: `Bearer ${token}`,15 'Content-Type': 'application/json',16 }17}1819serve(async (req) => {20 if (req.method === 'OPTIONS') return new Response('ok', { headers: corsHeaders })2122 try {23 const { action, params = {} } = await req.json()24 const headers = livechatHeaders()25 let resp: Response2627 switch (action) {28 case 'list_agents':29 resp = await fetch(`${LC_BASE}/configuration/agents`, { headers })30 break3132 case 'get_chat_stats': {33 const from = params.from || new Date(Date.now() - 30 * 86400000).toISOString().split('T')[0]34 const to = params.to || new Date().toISOString().split('T')[0]35 resp = await fetch(`${LC_BASE}/reports/chats/total_chats?from=${from}T00:00:00Z&to=${to}T23:59:59Z&distribution=day`, { headers })36 break37 }3839 case 'list_chat_archives':40 resp = await fetch(`${LC_BASE}/chats?${new URLSearchParams({41 page_id: params.pageId || '',42 sort_order: 'desc',43 ...(params.agentId && { filters: JSON.stringify({ agent_ids: [params.agentId] }) }),44 }).toString()}`, { headers })45 break4647 case 'get_chat_transcript':48 resp = await fetch(`${LC_BASE}/chats/${params.chatId}`, { headers })49 break5051 default:52 return new Response(JSON.stringify({ error: 'Unknown action' }), {53 status: 400, headers: { ...corsHeaders, 'Content-Type': 'application/json' },54 })55 }5657 const data = await resp.json()58 return new Response(JSON.stringify(data), {59 status: resp.ok ? 200 : resp.status,60 headers: { ...corsHeaders, 'Content-Type': 'application/json' },61 })62 } catch (error) {63 return new Response(JSON.stringify({ error: error.message }), {64 status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' },65 })66 }67})Pro tip: LiveChat's reports API uses different date formats than the chat archive API. Reports use ISO 8601 datetime strings (YYYY-MM-DDThh:mm:ssZ), while some archive endpoints use Unix timestamps. Check the API documentation for each specific endpoint's date format requirements.
Expected result: The livechat-api Edge Function deploys in Cloud → Edge Functions. Test with action 'list_agents' — your LiveChat agent list should appear in the response with their availability status.
Common use cases
Embed LiveChat widget with authenticated user identity
Add the LiveChat widget to your Lovable app so that when logged-in users start a chat, their name and email are automatically sent to the agent rather than requiring manual identification. The widget is initialized with user data from your Supabase Auth session, and agents see the customer's name, email, and any custom properties you pass (plan tier, account age, etc.) in the chat window.
Add the LiveChat widget to my Lovable app. When a user is logged in, initialize the LiveChat widget with their name (from user_metadata.full_name) and email. Also pass a custom variable 'plan' with their current subscription tier. When logged out, show the widget without pre-filled data. Use the VITE_LIVECHAT_LICENSE_ID environment variable for the license number.
Copy this prompt to try it in Lovable
Chat analytics dashboard showing agent performance and volume
Build an internal operations dashboard that fetches LiveChat analytics data: total chats by day, average response time, chat satisfaction ratings, and agent availability status. Managers see team performance at a glance without logging into LiveChat's reporting interface. The dashboard refreshes daily to show current metrics alongside historical trends.
Create an Edge Function called livechat-analytics that fetches chat volume, response time, and satisfaction ratings from the LiveChat Reports API using LIVECHAT_ACCESS_TOKEN and LIVECHAT_ACCOUNT_ID from secrets. Date range: last 30 days. Return total_chats, avg_response_time_seconds, satisfaction_good_count, and daily breakdown. Build a metrics dashboard in Lovable with KPI cards and a line chart for daily chat volume.
Copy this prompt to try it in Lovable
Chat archive viewer for compliance and review
Create an internal tool that fetches LiveChat chat archives for a specific date range or agent, displays full conversation transcripts, and allows managers to flag conversations for review. Chat transcripts are stored in Supabase for compliance purposes and searchable by keyword, date, or customer email — enabling quality assurance reviews without direct LiveChat access for every manager.
Create an Edge Function called livechat-archives that accepts { startDate, endDate, agentId } and fetches chat transcripts from the LiveChat Chats API using LIVECHAT_ACCESS_TOKEN and LIVECHAT_ACCOUNT_ID from secrets. Return chat ID, start time, agent name, customer email, rating, and message count. Build an archive viewer page with date range picker, agent filter, and expandable chat transcripts.
Copy this prompt to try it in Lovable
Troubleshooting
LiveChat API returns 401 Unauthorized with 'invalid access token' error
Cause: The Personal Access Token is incorrect, has expired, or was generated with insufficient scopes for the endpoint being called.
Solution: In the LiveChat Developer Console, verify the Personal Access Token is active and has the required scopes (chats--all:read, reports_read, agents--all:read). Generate a new token if needed and update the LIVECHAT_ACCESS_TOKEN secret. Personal Access Tokens in LiveChat expire after a configurable period — check the token's expiry in the Developer Console.
LiveChat chat widget does not appear on the Lovable app
Cause: The VITE_LIVECHAT_LICENSE_ID environment variable is not set, or the script is blocked by a Content Security Policy on the deployment.
Solution: Verify VITE_LIVECHAT_LICENSE_ID is configured as a build-time environment variable accessible via import.meta.env. Also check browser console for any CSP errors — LiveChat's CDN (cdn.livechatinc.com) must be allowed by your app's Content Security Policy. In Lovable, check if any custom headers are blocking external scripts.
Chat analytics returns empty data for the date range specified
Cause: The date format is incorrect for the LiveChat reports API, or no chats occurred in the specified date range.
Solution: LiveChat reports require ISO 8601 datetime with timezone: YYYY-MM-DDThh:mm:ssZ. Ensure the 'from' and 'to' parameters include the time component and 'Z' timezone suffix. A common mistake is using YYYY-MM-DD format (date only) which the reports API does not accept.
1// Correct date format for LiveChat Reports API:2const from = '2026-01-01T00:00:00Z' // MUST include time and Z suffix3const to = '2026-03-31T23:59:59Z'LiveChat widget shows the chat button but opening it shows 'Chat is currently unavailable'
Cause: No agents are currently online in LiveChat, or after-hours settings show the widget as unavailable.
Solution: This is expected behavior when all agents are offline or during configured unavailable hours. In LiveChat settings, you can configure the widget to show a contact form during offline hours instead of the unavailability message. Use the LiveChat JavaScript API to detect availability status: window.LiveChatWidget.on('availability_changed', handler) to update your UI based on chat availability.
Best practices
- Always pre-fill user identity (name and email) in the LiveChat widget for logged-in users — agents can provide better support when they immediately know who they are chatting with.
- Pass relevant context as session variables (plan tier, account age, last error) alongside user identity — this gives agents the information they need without asking the customer to repeat it.
- Use Personal Access Tokens with minimum required scopes rather than broad permissions — read-only tokens for analytics are safer than full-access tokens.
- Cache LiveChat analytics data in Supabase rather than fetching from the API on every dashboard load — chat metrics rarely change more than once per hour.
- Implement LiveChat availability detection in your app to show a contact form or async messaging option when no agents are online — do not leave users with an empty 'unavailable' widget.
- Store chat IDs for important conversations in your Supabase database when you need to retrieve transcripts later — the LiveChat archive API is paginated and searching for specific chats by customer email requires iterating through pages.
- Test the widget with Lovable's deployed app URL, not the editor preview — LiveChat may block widget initialization on localhost or non-registered domains.
Alternatives
Choose Intercom if you need in-app messaging with proactive outreach, help center, and chatbots in addition to live chat — Intercom is a more complete customer platform than LiveChat's focused chat service.
Choose Zendesk if you need a full ticket-based support system alongside chat — Zendesk's live chat (Zendesk Chat) integrates with its ticketing system for a unified support workflow.
Choose Freshdesk if you need an affordable all-in-one support platform with both ticketing and chat — Freshdesk's free plan includes chat and is significantly cheaper than LiveChat for small teams.
Frequently asked questions
Does LiveChat have a free plan?
LiveChat does not have a permanent free plan. A 14-day free trial is available, and the Starter plan is $20/agent/month billed annually. The Starter plan includes the chat widget, basic analytics, and API access. For small teams building Lovable integrations, the 14-day trial is sufficient for development and testing before committing to a plan.
Can I use LiveChat for both web and mobile apps built with Lovable?
Lovable builds web apps (React + Vite), not native mobile apps. The LiveChat JavaScript widget works in web browsers, including mobile browsers. If your Lovable app is accessed via mobile browser, the LiveChat widget is fully functional. For native iOS/Android apps, LiveChat offers separate mobile SDKs, but those are outside the scope of Lovable's web-based development.
How do I prevent the LiveChat widget from appearing on every page (like the admin dashboard)?
Use LiveChat's JavaScript API to conditionally show or hide the widget based on the current route. In your React app, add a useEffect that watches the router location and calls window.LiveChatWidget.call('hide') on admin-only pages, and window.LiveChatWidget.call('minimize') or window.LiveChatWidget.call('maximize') on customer-facing pages. The LiveChat widget respects these programmatic show/hide calls.
What is the difference between LiveChat and LiveChat's Chatbot product?
LiveChat is the human-agent chat product — real support agents receive and respond to chat conversations. ChatBot.com is a separate Livechat Inc. product for building automated chatbot flows that can answer questions without human agents. The two products integrate: ChatBot handles first-contact resolution attempts and escalates to LiveChat human agents when needed. This guide covers the LiveChat human-agent product. Building chatbot flows requires the separate ChatBot.com API integration.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation