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: Set Up ChatAds
- Create a ChatAds account and upload your Amazon Affiliate Associates ID (ChatAds is Amazon-only right now)
- Go to app.getchatads.com/api/keys and create an API key. Call it “Lovable” to keep track of it
Step 2: Configure Lovable
- Enable Cloud on your Lovable project
- Go to the Cloud setting in Lovable and add your ChatAds key as a Secret called
CHATADS_API_KEY
Step 3: Prompt Lovable
Copy and paste the prompt below into Lovable’s chat:Lovable Prompt
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. - Chat flow integration — After the AI generates a response, the app calls the proxy with the response text. If ChatAds finds product mentions, it inserts affiliate links into the text before the message is sent to the user.
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.