Project Name:
AI-Powered Ad Copy Generator built in Zapier
Why this project?
This project is a lightweight web API built with Python and Flask that takes customer reviews as input and uses an AI language model to automatically generate engaging advertising copy — including a title, description, and call to action (CTA). It’s designed to help marketers quickly transform raw customer feedback into polished promotional content.
Tech stack
Backend Framework: Flask — for creating the API server.
AI Model: Hugging Face Transformers (
flan-t5-base
) — for text generation without external paid APIs.Python Libraries:
transformers
— to load and run the AI model.torch
(PyTorch) — backend for running the model efficiently.
Development tools:
python-dotenv
— optional, for environment variables.watchdog
orflask
debug mode for auto-reloading code during development.
Key features
Accepts customer reviews in JSON format via HTTP POST.
Uses a prompt-engineered detailed instruction to guide the AI for structured output.
Returns JSON with distinct fields: title, description, call to action, and the original review.
Includes robust error handling for missing or invalid inputs.
Auto-reloads on code changes during development (using Flask debug mode).
Easily extendable for additional fields or different models.
Step 1: Scraping Reviews with Apify
I used an Apify actor (nikita-sviridenko/trustpilot-reviews-scraper) to scrape customer reviews or testimonials from websites, online stores, or review platforms.
Apify fetches reviews automatically and stores them in a dataset or pushes them via a webhook.
Apify’s output is a structured JSON with review text and other metadata.
Optionally, you can schedule the scraping actor to run regularly to keep your data fresh.
Step 2: Create a New Zap in Zapier
Log in to your Zapier account.
Click “Create Zap” to start a new workflow automation.
Add a Schedule by Zapier step and have it run how often you want. For this, I set it to every day at 10 AM.
Step 3: Trigger Zapier Workflow to Process Stored Reviews
The first action is a Zapier Storage — Retrieve Value step that fetches the stored JSON review data from Zapier Storage.
I parse this JSON to extract individual reviews for processing.
Step 4: Parse and Prepare Each Review
Next, you add a Code by Zapier step (JavaScript or Python).
In this step, you:
Parse the JSON string retrieved from Storage.
Extract individual reviews.
Format each review as needed for the API call.
Return the formatted review text or an array of reviews to loop over in the next steps.
import json
import random
raw = input_data['reviews']
# Try to decode once
try:
decoded_once = json.loads(raw)
except Exception as e:
raise Exception(f"Failed to decode JSON first time: {e}")
# If the result is a string, decode again (double-encoded JSON)
if isinstance(decoded_once, str):
try:
data = json.loads(decoded_once)
except Exception as e:
raise Exception(f"Failed to decode JSON second time: {e}")
else:
data = decoded_once
review = random.choice(data)
output = {
'text': review.get('reviewBody', ''),
'author': review.get('authorName', ''),
'date': review.get('datePublished', '')
}
Here is the code I used.
Step 5: Webhooks by Zapier — Send Each Review to Flask API
Again, this is a choice everyone makes. For me, running my own API locally works best. You can easily add a ChatGPT module in this step and configure it in Zapier .
Use Webhooks by Zapier (POST) to send each review to your custom Flask API endpoint.
The webhook payload includes the review text in JSON format.
Your Flask API runs the Hugging Face model and responds with generated ad copy (title, description, CTA).
Zapier captures the JSON response from your API.
In this last one you can see what the AI model sent back. We have Title, Description and CTA for our Ad.
Step 6: Google Sheets — Save Generated Ad Copy
Finally, the Zap inserts a new row into Google Sheets for each review processed.
Each row contains:
Original review text
Generated Title
Generated Description
Generated Call To Action (CTA)
This creates an organized log of all reviews and their AI-generated ad copy, easy to review or share.
In this example, I have created a new Spreadsheet. But, you can easily modify it so it can add a new row in an existing one instead.
And that's it! Did someone say automated Ad Copy based on your real customer reviews? Yes, please!