Overview
Lovable is an AI app builder that generates full-stack React applications. You can integrate ChatAds by giving Lovable a prompt — it will create a server-side function to proxy API calls and wire up the frontend automatically.No SDK install needed. Lovable handles the backend and frontend code generation from the prompt below.
Setup
Step 1: Get Your API Key
- Go to app.getchatads.com/api/keys
- Create an API key (starts with
cak_)
Step 2: Prompt Lovable
Copy and paste the prompt below into Lovable’s chat. Replacecak_your_api_key with your actual API key.
Lovable Prompt
Copy this entire prompt and paste it into Lovable:How It Works
The prompt creates a two-part integration:- Server-side function (
chatads-proxy) — Calls the ChatAds API with your key. Your key stays on the server and never reaches the browser. - Frontend — Calls the proxy after content renders, then replaces matching product mentions with affiliate links.
Troubleshooting
401 Unauthorized errors
The API key isn’t reaching the ChatAds API. Ask Lovable:CORS errors
If the frontend can’t call the function, ask Lovable:No affiliate links appearing
- Test your message in the API Explorer first to confirm it returns offers
- Check the browser console for errors from the function call
- Verify the frontend is checking
data.returned > 0before replacing text
Response Reference
| Field | Type | Description |
|---|---|---|
data.status | string | "filled" if offers found, "empty" otherwise |
data.returned | number | Number of offers returned |
data.offers[].link_text | string | Text to match in the original message |
data.offers[].url | string | Affiliate link URL |
data.offers[].product.title | string | Product name |
data.offers[].product.stars | number | Product rating (0-5) |
data.offers[].product.reviews | number | Review count |
Best Practices
Keep keys server-side
The server-side function keeps your API key off the browser. Never put it directly in frontend code.
Don't block rendering
Show content immediately and update with affiliate links when the API responds. Users shouldn’t wait for ChatAds.
Handle empty gracefully
Not every message will have affiliate matches. Always check
data.returned > 0 before modifying text.Test in API Explorer
Verify your messages return offers in the API Explorer before debugging Lovable code.