Overview
Replit is an online IDE and AI app builder. You can integrate ChatAds using Replit Agent or by installing the TypeScript or Python SDK directly through the built-in package manager.Replit supports both TypeScript/Node.js and Python — use whichever SDK matches your project.
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 “Replit” to keep track of it
Step 2: Add Your API Key as a Secret
- Open your Repl
- Go to Tools → Secrets in the sidebar
- Add a new secret: key =
CHATADS_API_KEY, value = your API key
Step 3: Install the SDK
Step 4: Call the API
Using Replit Agent
If you prefer to use Replit’s AI agent, paste this prompt:Troubleshooting
401 Unauthorized errors
Your API key isn’t being read. Verify the secret name matches exactly:- Go to Tools → Secrets
- Confirm the key is named
CHATADS_API_KEY(case-sensitive) - Make sure you’re reading it with
process.env.CHATADS_API_KEY(Node) oros.environ["CHATADS_API_KEY"](Python)
Module not found
If the SDK isn’t installing, check yourpackage.json or requirements.txt:
- TypeScript: run
npm install @chat-ads/chatads-sdkin the Shell tab - Python: run
pip install chatads-sdkin the Shell tab
No affiliate links appearing
- Test your message in the API Explorer first to confirm it returns offers
- Check the Replit console for errors
- Verify you’re 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
Use Replit Secrets
Never hardcode your API key. Always use Replit’s Secrets feature to keep credentials secure.
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 Replit code.