AI Ad copy generator

Building an AI-Powered Amazon Ad Copy Generator with Flask and Gemini

This post is part of the GenAI Series.

Back-to-back GenAI-related posts, but I could not resist writing this post instead of a trading-related one.

A few days ago, I built a small tool that lets you input an Amazon ASIN and instantly generate marketing copy, including Facebook ads, Amazon A+ content, and SEO product descriptions by using Gemini. The frontend is built with Bootstrap + jQuery, and the backend runs on Python Flask. While this was originally aimed at Amazon sellers, it turned out to be a fun exercise in prompt engineering, tool chaining, and turning structured product data into persuasive, persona-targeted content.

If you are in a hurry, then watch the video demo below; otherwise, read on.



The very first goal was to fetch real-time product information from the Amazon website. Scraping Amazon is not an easy task, so there must be an easier way to do it. Thankfully, ScraperAPI offers an easy-to-use API that makes life easier. ScraperAPI provides something they call Structured Data Endpoints or SDE, which actually takes all the burden of worrying about IP bans, network throttling, bot detection, and dynamic HTML. You access the relevant endpoint and fetch information either in JSON or Markdown format. They also provide SDE endpoints for Google products like Maps, Shopping, Walmart, and eBay.

Alright, so the goal is to use ScraperAPI’s SDE endpoint to fetch the product data like title and description, etc., and pass this on to Gemini to get different types of ad copy.

Development

Since this is a Flask app, you should have Flask installed. You will also need the Google GenAI library installed. You will also need an API key that you can create here. The ScraperAPI SDE endpoint for Amazon returns the following JSON payload against the product’s ASIN:

{
  "name": "Polk Audio Atrium 6 Outdoor All-Weather Speakers with Bass Reflex Enclosure (Pair, Black), Broad Sound Coverage, Speed-Lock Mounting System",
  "product_information": {
    "mounting_type": "Outside Mount,Atrium",
    "material": "Plastic",
    "model_name": "Atrium 6",
    "speaker_type": "Outdoor",
    "special_feature": "Built In Microphone",
    "recommended_uses_for_product": "For Music Players",
    "compatible_devices": "Television",
    "subwoofer_diameter": "5.25 Inches",
    "unit_count": "1.0 Count",
    "controller_type": "Button",
    "surround_sound_channel_configuration": "2.0",
    "color": "Black",
    "included_components": "Online Product Registration card, 2 Mounting brackets (installed) Owner's Manual, 2 Black all-weather speakers, Polk Audio brochure",
    "product_dimensions": "8.8\"D x 7.7\"W x 11.7\"H",
    "age_range_description": "Adult",
    "item_weight": "5.4 pounds",
    "impedance": "8 Ohm",
    "is_waterproof": "TRUE",
    "warranty_type": "Full",
    "number_of_items": "2",
    "control_method": "Touch",
    "wireless_communication_technology": "Bluetooth",
    "speaker_size": "5.25 Inches",
    "power_source": "Corded Electric",
    "woofer_diameter": "5.25 Inches",
    "tweeter_diameter": "1 Inches",
    "vehicle_service_type": "Car",
    "water_resistance_level": "Not Water Resistant",
    "customer_package_type": "Standard Packaging",
    "audio_driver_type": "Dynamic Driver",
    "number_of_microphones": "1",
    "audio_driver_size": "5.25 Inches",
    "subwoofer_connectivity_technology": "Wired",
    "connectivity_protocol": "Bluetooth",
    "includes_mp_3_player": "No",
    "number_of_circuits": "1",
    "number_of_power_levels": "1",
    "series_number": "6",
    "upc": "747192118853",
    "style": "Atrium 6 (Pair)",
    "indoor_outdoor_usage": "Outdoor",
    "global_trade_identification_number": "00747192118853",
    "manufacturer": "Polk Audio",
    "asin": "B00378KMGE",
    "country_of_origin": "China",
    "item_model_number": "Atrium 6 Black",
    "customer_reviews": {
      "ratings_count": 9684,
      "stars": 4.6
    },
    "best_sellers_rank": [
      "#4,435 in Electronics (See Top 100 in Electronics)",
      "#11 in Outdoor Speakers"
    ],
    "is_discontinued_by_manufacturer": "No",
    "date_first_available": "February 1, 2010"
  },
  "brand": "Visit the Polk Audio Store",
  "brand_url": "https://www.amazon.com/stores/PolkAudio/page/40123731-16B2-43A8-AF71-A79617EA46E3?lp_asin=B00378KMGE&ref_=ast_bln&store_ref=bl_ast_dp_brandLogo_sto",
  "full_description": "A workhorse when it comes to filling large spaces with the kind of big, lifelike high quality sound for all your outdoor entertainment. Atrium 6 speakers are All-Weather Certified and Water-Resistant—built to withstand the worst elements—salt-fog, UV, extreme temps or heavy rains, you name it. Aluminum grilles and bracket, with stainless steel and brass hardware means no rust—ever. Polk’s patented Dynamic Balance technology with 5.25\" Driver, 1\" Tweeter and Power Port Bass Venting analyzes the speaker’s entire electro-acoustic and mechanical system for improved material selection and more efficient geometry. These speakers are easy to install and look great both outdoors and indoors.",
  "pricing": "$259.00",
  "list_price": "$425.00",
  "shipping_price": "FREE",
  "shipping_time": "Saturday, July 12",
  "shipping_condition": "Saturday, July 12",
  "shipping_details_url": "/gp/aag/details/?seller=A17MC6HOH9AVE6&sshmPath=shipping-rates",
  "availability_status": "In Stock",
  "is_coupon_exists": false,
  "images": [
    "https://m.media-amazon.com/images/I/41Awqb-jcmL.jpg",
    "https://m.media-amazon.com/images/I/51jxDjsPIBL.jpg",
    "https://m.media-amazon.com/images/I/41KQrU9sCWL.jpg",
    "https://m.media-amazon.com/images/I/41dwHqIMRUL.jpg",
    "https://m.media-amazon.com/images/I/51Nlb1oAvML.jpg",
    "https://m.media-amazon.com/images/I/51Q4jC6Lm0L.jpg"
  ],
  "product_category": "Electronics›Home Audio›Speakers›Outdoor Speakers",
  "average_rating": 4.6,
  "feature_bullets": [
    "ALL WEATHER CERTIFICATION - The speaker for all seasons. With rugged durability and premium build, these speakers can effortlessly withstand all elements including extreme temperatures and heavy rain",
    "DEEP EFFORTLESS BASS - Equipped with 5 ¼” dynamic balance polypropylene woofers, 1” anodized aluminum dome tweeters, and PowerPort bass venting, these speakers provide wider sound dispersion and excellent clarity",
    "EXCEPTIONALLY GREAT SOUND - Install your Atrium 6 speakers in any large or open outdoor space – by the pool, on the patio or in the sunroom. Experience excellent sound no matter where you set them up",
    "BLEND IN ANYWHERE - These loudspeakers come with a steeply-angled baffle design that can be hidden underneath overhangs or even tucked under pergolas",
    "EASY INSTALLATION - Atrium’s one-click speed-lock mounting bracket offers easy, one-handed installation. Mount these speakers vertically or horizontally, simply mount the C bracket, adjust the angle, and fasten the speaker with a click"
  ],
  "total_reviews": 9684,
  "model": "Atrium 6 Black",
  "customization_options": {
    "color": [
      {
        "asin": "B00378KMGE",
        "is_selected": true,
        "value": "Black",
        "image": "https://m.media-amazon.com/images/I/41htuAhng7L.jpg"
      },
      {
        "asin": "B00378KMG4",
        "is_selected": false,
        "value": "White",
        "image": "https://m.media-amazon.com/images/I/51wqk6bnumL.jpg"
      }
    ],
    "style": [
      {
        "asin": "B00378KMF0",
        "is_selected": false
      },
      {
        "asin": "B00378KMFU",
        "is_selected": false
      },
      {
        "asin": "B00378KMGE",
        "is_selected": true
      },
      {
        "asin": "B00378KMIC",
        "is_selected": false
      }
    ]
  },
  "seller_id": "A17MC6HOH9AVE6",
  "seller_name": "Adorama",
  "ships_from": "Adorama \n                                            Adorama          Ships from       Adorama",
  "aplus_present": true,
  "customers_say": {
    "summary": "Customers find these outdoor speakers deliver excellent sound quality and value for money. They are well-built, with one customer noting they've lasted over 10 years, and feature easy-to-use mounting brackets. Customers appreciate the speakers' size, with one mentioning they're large enough to fill a church, and their appearance, particularly how the white finish looks under a back porch. Customers praise the speakers' performance on patios and their ability to maintain clarity at both low and high volumes.",
    "select_to_learn_more": {
      "value_for_money": {
        "total": 605,
        "positive": 557,
        "negative": 48
      },
      "ease_of_installation": {
        "total": 542,
        "positive": 538,
        "negative": 4
      },
      "build_quality": {
        "total": 442,
        "positive": 381,
        "negative": 61
      },
      "size": {
        "total": 271,
        "positive": 226,
        "negative": 45
      },
      "look": {
        "total": 238,
        "positive": 230,
        "negative": 8
      },
      "work_quality": {
        "total": 234,
        "positive": 210,
        "negative": 24
      },
      "clarity": {
        "total": 154,
        "positive": 148,
        "negative": 6
      }
    }
  },
  "total_ratings": 9684,
  "5_star_percentage": 80,
  "4_star_percentage": 11,
  "3_star_percentage": 4,
  "2_star_percentage": 2,
  "1_star_percentage": 3,
  "reviews": [
    {
      "stars": 5,
      "date": "Reviewed in the United States on July 9, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Zeek the Geek",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AH5QGRBANHAGIE4KGH4G66K2B4HQ/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "5.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    A very good speaker!",
      "review": "I go through outdoor speakers every few years.  The last set (Monoprice) lasted 5-6 years(?), but I suspect the woofer surrounds rotted out a couple of years ago; they were 50% completely missing! They never sounded very good either. The all-good reviews on the Polk Atrium 5 looked like they could be worth the higher cost than I usually pay. So I snapped up a \"Used - Mint Condition\" pair that actually looked unopened.Bingo! The bass is very good for a 5\" woofer, with reasonably extended lows.  Very clear sound overall.  Time will tell if they can handle our hot dry So. California sun better than the rest.  \n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R2PEMWU90GAFOR/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the United States on June 16, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Casey Moore",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AEA5O7HNW7OE6HTNAJHX3F3HK2EA/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "5.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    Great Quality HiFi Outdoor Speakers",
      "review": "I installed these on my pool lanai to replace some old speakers I had. I am blown away by them. From my pool I have perfect stereo imaging. What that means, is that not only does it sound great, but it does not have to be loud to hear all the details of the music. My neighbors definitely apricate that. I'm a HiFi geek and these absolutely satisfy my audiophile needs. I had thought about going with the larger version but these are perfect for my needs. These are powered by the Zone Two of my Onkyo RZ50 (I highly recommend as well) which is 120w per channel. That power definitely helps, but I'm sure these will sound great off of any decent amp. If you are looking for a good quality outdoor speaker I guarantee you will be more then happy with these.\n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R374W750P0L4GJ/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "total_found_helpful": 5,
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the United States on July 7, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "GazerdudeGazerdude",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AFIZPNF2YITWVJMW7J7J2GPR2SCA/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "5.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    2 years+ use and still awesome",
      "review": "I've had them 2 years now. Outside, fully exposed mounted on posts, no roof. They still sound as awesome as they did the first day. The speaker wires I used needed replaced, as they were not rated for outdoors, after a year and a half. But these speakers are awesome. Had the first set for a business and then got a set for myself. \n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R2EAKVZ0TFC51I/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "total_found_helpful": 1,
      "images": [
        "https://images-na.ssl-images-amazon.com/images/G/01/x-locale/common/grey-pixel.gif",
        "https://m.media-amazon.com/images/I/71OZAKs8QzL.jpg"
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the United States on June 19, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Eric B.Eric B.",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AFJSP42CBIHKBMU6SVNNN5JKIS5Q/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "5.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    Great sound. Easy to install. March colors perfectly.",
      "review": "So glad I purchased these. Sound great in my backyard. Easy to install. White isn’t super bright so it blends in nicely. Far superior than the previous black speakers (not sure of brand) we had in terms of sound quality and aesthetic. Recommend the Atrium 6 vs Atrium 5 since these have bass ports for richer sound.\n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R2612ZMDTHVONT/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "total_found_helpful": 1,
      "images": [
        "https://images-na.ssl-images-amazon.com/images/G/01/x-locale/common/grey-pixel.gif",
        "https://m.media-amazon.com/images/I/71-Axv6FQqL.jpg"
      ],
      "variation": {
        
      }
    },
    {
      "stars": 4,
      "date": "Reviewed in the United States on July 6, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Jeffrey Timor",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AHSKVYODZBIPBTUDULDBVS23SARQ/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "4.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    4 years of quality service. No more",
      "review": "Ran well for 4 years and began faltering, I guess expect 4 years of quality sound.I had them under the roof overhang, they would not get wet.\n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R2RWCDOEU887VH/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the United States on July 5, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "K. Williams",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AGV5E2FMHZMCDTICEATI2HTTA77Q/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "5.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    Great sounding speakers",
      "review": "These speakers are the flagship. They sound very good easy install . happy with this purchase.\n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R1DFJ9N4X4XJZS/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the United States on May 21, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Amazon Customer",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AHOARNNQRFZI6L5FEAMUAX5KXMXA/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "5.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    Just buy these",
      "review": "Just spring for the $400 for a pair.. These sound amazing and fill my whole backyard with quality audio. They sound so much better than the Bose that they replaced. Crisp highs and surprisingly low lows. They are a little larger but I mounted them on the ceiling and they just blend in well. Pointed down at 45° they fill the area and don't sound like they're above.  Time will tell about durability, but  sound quality is very good out of the box...and that's from a very picky audiophile. Pushing these with a nice Sony 600w receiver...which is overkill...but there's no substitute for power and they handle half volume with no distortion with a rich full sound.\n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R2BVFI29QY09V4/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "total_found_helpful": 10,
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the United States on June 6, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Patrick R.",
      "user_url": "https://www.amazon.com/gp/profile/amzn1.account.AEUT3VBCDWN65TLO6YUMFATUCEKQ/ref=cm_cr_dp_d_gw_tr?ie=UTF8",
      "title": "5.0 out of 5 stars\n\n\n\n\n\n\n\n  \n  \n    Crank it up, these can handle it!",
      "review": "Bought and installed these outdoors over 5 years ago.  Connected to a powerful OldSchool Stereo and play music via a Bluetooth module. Excellent sound, Excellent durability. I would almost say they are Hurricane proof, mounted outside under the eave of my home, weathered many Florida storms.. and they still sound as good as day one.  Crank it Up, they can handle it.\n  \nRead more",
      "review_url": "https://www.amazon.com/gp/customer-reviews/R1ZQQD4ZJPY8KV/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B00378KMGE",
      "total_found_helpful": 2,
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 1,
      "date": "Reviewed in Australia on July 31, 2022",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Wayne",
      "title": "Won't handle a 75 watt amp yet rated at 100 watts",
      "review": "I loved these speakers when I got them. I listened to music every opportunity I had.To my disappointment the tweeters stopped working and now sound dull and nasty.These speakers are rated 100 Watts. My Bluetooth amp is maxed at 75 watts with its current power supply. So can polk audio please explain why my tweeters are blown within 8 months of purchase. So much for all the research I did. I've never had tweeters blow on me. Now I'm trying to find replacement tweeters with no luck after searching Internet for a day.mlike how hard does this need to be.\n  \nRead more",
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 1,
      "date": "Reviewed in Singapore on December 19, 2022",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "MalarMalar",
      "title": "Dented speakers",
      "review": "Despite the panicking both speakers grilles canne surf a slight dent as shown in three pictures.\n  \nRead more",
      "images": [
        "https://images-na.ssl-images-amazon.com/images/G/01/x-locale/common/grey-pixel.gif",
        "https://m.media-amazon.com/images/I/61I1N+K3GkL.jpg"
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the United Kingdom on June 30, 2022",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Phillip Dickenson Phillip Dickenson",
      "title": "Look and feel quality",
      "review": "Great looking, outdoor speakers, the sound quality is sufficient to get the party in full swing, easy to install.\n  \nRead more",
      "images": [
        "https://images-na.ssl-images-amazon.com/images/G/01/x-locale/common/grey-pixel.gif",
        "https://m.media-amazon.com/images/I/81okHT63QqL.jpg",
        "https://images-na.ssl-images-amazon.com/images/G/01/x-locale/common/grey-pixel.gif",
        "https://m.media-amazon.com/images/I/71cPxs1Y04L.jpg"
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in Australia on April 10, 2025",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Richard",
      "title": "Going great.",
      "review": "Had these speakers out on my deck under a roof. They have been going great. The front metal grills are showing some corrosion but we are about 100m from the sea, but otherwise all good.\n  \nRead more",
      "images": [
        
      ],
      "variation": {
        
      }
    },
    {
      "stars": 5,
      "date": "Reviewed in the Netherlands on August 14, 2021",
      "verified_purchase": false,
      "manufacturer_replied": false,
      "username": "Thierry G",
      "title": "Buitengewone waarde voor uw geld",
      "review": "Het geluid is perfect op het terras en is zeer goed uitgebalanceerd.  De bassen zijn perfect.  Een zeer goed product.\n  \n  \nRead more",
      "images": [
        
      ],
      "variation": {
        
      }
    }
  ]
}

For the sake of this demo, I am going to pass the entire JSON.

Alright, so there are two prompts involved in it: the first takes the product data and figures out the target audience, and the second one generates the actual ad copy.

Let’s do a bit of prompt engineering. We will be writing the first prompt that takes product JSON data and returns a list of the target audience. If you do not know about prompt engineering, then I would recommend reading my post here.

Target Audience Prompt

Below is the system prompt that suggests the target audience for the product:

You are a marketing strategist.

Given the following product JSON data, analyze the product specifications, features, design elements, tone of customer reviews, and potential emotional or practical benefits.

Based on that, return a JSON array of recommended target audiences who are most likely to resonate with this product. Focus on demographics, personas, or niche interests (e.g., "Christian moms", "teen girls", "skincare lovers", "makeup professionals", etc.).

Only output the result as a clean JSON array like below:

[
  "Christian moms",
  "Teen girls interested in makeup",
  "Women who travel frequently",
  "Buyers looking for faith-inspired gifts",
  "People with vision impairments needing magnification"
]

Do not include any explanation, notes, markdown, or text outside the JSON.

The relevant Flask endpoint is:

@app.route('/get_audiences', methods=['POST'])
def get_audiences():
    asin = request.form.get('asin')
    product_json = json.dumps(get_product(asin), separators=(',', ':'))
    # print(product_json)

    prompt_audience_file = "prompt_audience.txt"
    prompt_audience = None
    with open(prompt_audience_file, encoding="utf8") as f:
        prompt_audience = f.read()

    # Replace the placeholder with the actual product json
    prompt_audience = prompt_audience.replace("{product_json}", product_json)
    # print(prompt_audience)
    response = client.models.generate_content(
        model="gemini-2.5-flash",
        config=types.GenerateContentConfig
            (
            system_instruction=prompt_audience,
            response_mime_type="application/json",
        ),
        contents=product_json
    )
    # Mock suggested audiences
    audience_list = json.loads(response.text)

    return jsonify({
        "audiences": audience_list,
        "product": product_json
    })

When I execute this endpoint it returns:

{
  "audiences": [
    "Music lovers who enjoy listening to audio in the shower",
    "Tech enthusiasts and early adopters interested in innovative gadgets",
    "Environmentally conscious consumers seeking products made from recycled materials",
    "Individuals looking for convenient, low-maintenance smart home or bathroom accessories",
    "People who value hands-free control and continuous power for their devices"
  ],
  "product": "{\"name\":\"Ampere Shower Power - Hydropower Bluetooth Shower Speaker, Waterproof Detachable Portable, Rechargeable Mini Speaker (Chrome)\",\"product_information\":{\"material\":\"Recycled ocean plastic\",\"model_name\":\"Hydropower\",\"speaker_type\":\"Surround Sound\",\"special_feature\":\"Waterproof, Stereo Pairing\",\"recommended_uses_for_product\":\"Bathroom\",\"compatible_devices\":\"iPhone, Tablet, Smartphone\",\"subwoofer_diameter\":\"0.05 Meters\",\"controller_type\":\"Remote Control\",\"surround_sound_channel_configuration\":\"2.0\",\"color\":\"Chrome\",\"age_range_description\":\"Adult\",\"item_weight\":\"1.95 pounds\",\"is_waterproof\":\"True\",\"charging_time\":\"12 Hours\",\"warranty_type\":\"Limited\",\"maximum_range\":\"10 Meters\",\"number_of_items\":\"1\",\"control_method\":\"App\",\"wireless_communication_technology\":\"Bluetooth\",\"speaker_size\":\"45 Millimeters\",\"power_source\":\"Hydropower\",\"water_resistance_level\":\"Waterproof\",\"number_of_batteries\":\"1 Lithium Ion batteries required. (included)\",\"audio_driver_type\":\"Dynamic Driver\",\"bluetooth_range\":\"10 Meters\",\"subwoofer_connectivity_technology\":\"Wireless\",\"connectivity_protocol\":\"Bluetooth\",\"includes_mp_3_player\":\"No\",\"specific_uses_for_product\":\"Bathroom\",\"upc\":\"723707106287\",\"style\":\"Shower Power\",\"manufacturer\":\"Ampere\",\"package_dimensions\":\"7.76 x 4.41 x 4.09 inches\",\"item_model_number\":\"SHPHCH05\",\"batteries\":\"1 Lithium Ion batteries required. (included)\",\"item_package_quantity\":\"1\",\"special_features\":\"Waterproof, Stereo Pairing\",\"batteries_included\":\"Yes\",\"batteries_required\":\"Yes\",\"battery_cell_type\":\"Lithium Ion\",\"asin\":\"B09R93MDJX\",\"customer_reviews\":{\"ratings_count\":72,\"stars\":3.4},\"best_sellers_rank\":[\"#568,359 in Electronics (See Top 100 in Electronics)\",\"#10,447 in Portable Bluetooth Speakers\"],\"date_first_available\":\"January 27, 2022\"},\"brand\":\"Visit the Ampere Store\",\"brand_url\":\"https://www.amazon.com/stores/Ampere/page/9C39E858-3C64-4A00-8874-12B8AADCAB6B?is_byline_deeplink=true&deeplink=05DA9084-7596-43E9-95F2-B3E474C92A9E&redirect_store_id=9C39E858-3C64-4A00-8874-12B8AADCAB6B&lp_asin=B09R93MDJX&ref_=ast_bln\",\"full_description\":\"Product Description 360\\u00b0 SPEAKERS                                         The cylindrical design delivers immersive audio that plays evenly in all directions. BIG BUTTONS                                        Play, pause and skip tracks directly on the speaker with the big easy-to-touch buttons. ALWAYS HAVE MUSIC IN THE SHOWER                                        Once installed, Shower Power never needs to be removed.\",\"availability_status\":\"Currently unavailable.                                  We don't know when or if this item will be back in stock.\",\"is_coupon_exists\":false,\"images\":[\"https://m.media-amazon.com/images/I/31KKeBcl-NL.jpg\",\"https://m.media-amazon.com/images/I/41gv1XZqBmL.jpg\",\"https://m.media-amazon.com/images/I/41Qw+17FCEL.jpg\",\"https://m.media-amazon.com/images/I/31PSESERa4L.jpg\",\"https://m.media-amazon.com/images/I/41sU4zf0Y6L.jpg\",\"https://m.media-amazon.com/images/I/519iXpFvQJL.jpg\"],\"product_category\":\"Electronics\\u203aPortable Audio & Video\\u203aPortable Speakers & Docks\\u203aPortable Bluetooth Speakers\",\"average_rating\":3.4,\"total_reviews\":72,\"model\":\"SHPHCH05\",\"aplus_present\":true,\"total_ratings\":72,\"5_star_percentage\":38,\"4_star_percentage\":20,\"3_star_percentage\":10,\"2_star_percentage\":14,\"1_star_percentage\":18,\"reviews\":[{\"stars\":5,\"date\":\"Reviewed in the United States on September 1, 2022\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"ibuystuff\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AFOB2KEWTQPMTLBQLJY2OWO7YVBA/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"5.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    this thing rules\",\"review\":\"I have been using a battery-powered waterproof speaker for years. When I heard about this I bought it right away. Easy installation, sounds very good, but when the speaker gets wet there is sometimes distortion. I think this is more of an early-adopter product. You should know that it is really big, make sure you take a look at the measurements. My wife was like what the hell is that thing on the showerhead?! But it works so well, it charges the battery seamlessly whenever the water is running, we have experienced no change in water pressure. The speaker comes off so you can place it wherever you want. Love it.\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R3DHWOTGECDOKU/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"total_found_helpful\":1,\"images\":[],\"variation\":{}},{\"stars\":1,\"date\":\"Reviewed in the United States on December 2, 2024\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"Ms. Andrews\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AE4Z4QAS7DMW7T64GQBMGKW3YHZA/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"1.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    Don't buy, hydropower charger broke twice\",\"review\":\"I brought this speaker because of the hydropower charger.  Unfortunately, it doesn't last. I take a shower every day so my speaker should never run out of power.  While it did because the hydropower broke on me twice.  The company did replace it the first time because it was still under factory warranty.  Now it past the one year warranty and its broke again.\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R3QN87AEUEN9IX/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"images\":[],\"variation\":{}},{\"stars\":4,\"date\":\"Reviewed in the United States on August 27, 2023\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"CW\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AEYWZBVKC7AHEWUF5B2VBIFAFAMA/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"4.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    Lasted 6 months\",\"review\":\"The media could not be loaded.\\n                \\n            \\n                \\n            \\n            \\n        \\n    \\n    \\n\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    Update: I've updated the review from a 2 to a 4 star.  Something I didn't think of before until I got the warranty replacement in the mail yesterday, my original order was apparently tampered with or a reconditioned unit.  It had another sticker over the original one sealing the box.  Well, my warranty replacement did too.  I paid for a new unit, and received a reconditioned one.  I will say they stood by the warranty and replied to me via this review, not my email to them. Installed the unit today, no leaks.---------We love the idea of this speaker.  This is our second one.  We remodeled our bathroom and had to get a black one instead of the first silver one we bought.  At 6 months, it developed a leak inside the unit.  At first, I thought it was at one of the connections, so I took it down, reapplied Teflon tape, and reinstalled. Then the leak got worse.  You can see how bad it is now on the video.  This unit was installed 6 months ago.It wouldn't fully charge from the water flow either, so every month or so, if have to plug the speaker into the wall to fully charge.  The turbine may have helped maintain the battery but it would slowly go down over the course of the month.If the manufacturer stands by their warranty, I'll update this review. [Updated- they sent me a \\\"new\\\" unit.]\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R1EH17VT5E072T/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"total_found_helpful\":1,\"images\":[],\"variation\":{},\"video_url\":\"https://m.media-amazon.com/images/I/B1FGrOPgiGL.mp4\"},{\"stars\":2,\"date\":\"Reviewed in the United States on August 3, 2022\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"EKanas\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AH4UAKMJJHS3GFW4JDKRNY2CS5VA/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"2.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    Ok, but not great.\",\"review\":\"The speaker is a great idea but not ready for prime time. The speaker is not very loud and makes an awful whining sound. I assume it\\u2019s the turbine charging the battery. The battery life if not great. I guess maybe I don\\u2019t shower long enough because it never stayed charged long enough.\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R13FVOB5H8JQR0/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"total_found_helpful\":4,\"images\":[],\"variation\":{}},{\"stars\":5,\"date\":\"Reviewed in the United States on March 26, 2023\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"David J. Weaver\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AHWSLNFAX4U3UCIAZEYKQK47NQNQ/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"5.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    Great shower speaker\",\"review\":\"I rated battery life at 5 because it lasts a long time.  You have the option of extremely charging it but if you have good water pressure and flow that isn't even an issue.  Sounds quality is good but I wish it were just a tad louder.You can add a second speaker for true stereo surround. You can also add a remote.  You can use this without having the shower running which is nice.\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R2ZR9ACQPBWQAO/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"images\":[],\"variation\":{}},{\"stars\":3,\"date\":\"Reviewed in the United States on March 25, 2023\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"J. Ng\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AEUL4B2DMM5HRNLXF4Z3YBVXDWIQ/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"3.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    Could be better\",\"review\":\"Battery life is short. Shower has to be at full blast to charge. Bluetooth connection gets lost every once in a while (in the middle of the shower session) and the randomly reconnects. Good for a first try but not really ready for prime time. Also, it's HUUUGE so if you have a removable shower head then this has to connect to the wall pipe and you might not be able to hang your shower head anymore so get a separate shower head holder that you can stick beside it.\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R32R0C1ZODK8AM/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"total_found_helpful\":2,\"images\":[],\"variation\":{}},{\"stars\":5,\"date\":\"Reviewed in the United States on January 28, 2023\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"GreenGreen\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AEJRQZDLGQRPACZSI43VC7NC76TA/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"5.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    It\\u2019s expensive but just buy it\",\"review\":\"VERY easy to install (literally takes a few seconds). Speaker is amazingly loud(you can control the volume!) and the sound quality is amazing. The fact you do NOT have to charge it (it\\u2019s powered by the water flowing) is why I bought it. I am very glad I bought it. The speaker is a bit expensive but I will say my I do love it. Very easy to connect to Bluetooth cell phone (or wherever you play your music from).\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R26MX8HYH649DE/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"total_found_helpful\":2,\"images\":[\"https://images-na.ssl-images-amazon.com/images/G/01/x-locale/common/grey-pixel.gif\",\"https://m.media-amazon.com/images/I/71ZqA0jlYfL.jpg\"],\"variation\":{}},{\"stars\":1,\"date\":\"Reviewed in the United States on July 13, 2022\",\"verified_purchase\":false,\"manufacturer_replied\":false,\"username\":\"Ms. Watson\",\"user_url\":\"https://www.amazon.com/gp/profile/amzn1.account.AEYYU7GPIQOKLSDWNTLCPA6TTCMA/ref=cm_cr_dp_d_gw_tr?ie=UTF8\",\"title\":\"1.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n  \\n  \\n    Completely Disappointed\",\"review\":\"I was so excited to get this product for my brother since he likes to listen to music in the shower. What you realize when you use it is that you are paying for the technology side of it. The whole, \\\"charges with water\\\" thing. That is great but the sound quality is really what matters, especially for this price point. I returned it for my money back.\\n  \\nRead more\",\"review_url\":\"https://www.amazon.com/gp/customer-reviews/R3NZYGPHGR78WQ/ref=cm_cr_dp_d_rvw_ttl?ie=UTF8&ASIN=B09R93MDJX\",\"total_found_helpful\":1,\"images\":[],\"variation\":{}}]}"
}

At the frontend, it is displayed like below:

Ad Copy Prompt

Below is the system prompt that generates the Ad copy for the product:

### PERSONA
The target audience for this marketing copy is: {persona}

### CORE LOGIC
You are a skilled AI marketing copywriter. Given a detailed JSON object describing a product (including specs, reviews, and attributes), analyze the product features, benefits, and sentiment.

Understand the product from a marketing perspective. Identify what would appeal most to the specified persona based on the available data. Focus on emotional benefits, practical utility, and standout features such as design, lighting, symbolism, or ease of use.

### OUTPUT FORMAT
Generate only the final ad copy in **Markdown format**, with no title, no labels, no preface, and no suffix. Do not include anything like "Here is the copy" or "Targeted at...".

The style should include:
- A bold, catchy hook
- A short intro paragraph
- 2–3 benefit-based bullet points
- A strong call to action at the end

All content must be tailored to the persona and grounded in the product details below.

And the relevant Flask endpoint:

@app.route('/generate_copy', methods=['POST'])
def generate_copy():
    persona = request.form.get('persona')
    output_type = request.form.get('output_type')
    product_json = json.loads(request.form.get('product_json'))

    prompt_ads_file = "prompt_ad_copy.txt"
    prompt_ads = None
    with open(prompt_ads_file, encoding="utf8") as f:
        prompt_ads = f.read()

    prompt_ads = prompt_ads.replace("{persona}", persona)
    response = client.models.generate_content(
        model="gemini-2.5-flash",
        config=types.GenerateContentConfig
            (
            system_instruction=prompt_ads,
        ),
        contents=product_json
    )

    copy = response.text.strip()
    return jsonify({"copy": copy})

When you execute this endpoint, it returns:

{
    "copy": "**Never Let the Music Stop: Your Shower's New Powerhouse Has Arrived!**\n\nTransform your daily routine into a concert with the Ampere Shower Power. Designed for music lovers who crave continuous sound even in the most relaxing space, this innovative speaker uses the flow of your shower to keep the melodies going, endlessly.\n\n*   **Effortless & Endless Power:** Say goodbye to charging cables! This groundbreaking speaker harnesses hydropower, ensuring your favorite tunes are always ready to play, without ever needing to leave your shower.\n*   **Immersive 360\u00b0 Audio:** Experience rich, evenly distributed sound that fills your entire bathroom, making every shower a private jam session. Plus, with simple, oversized buttons, control is always at your fingertips.\n*   **Unleash Your Sound:** Waterproof and detachable, you can easily take the speaker from its hydropower base to keep the party going outside the shower, giving you versatile sound wherever you go.\n\nElevate your shower experience and dive into uninterrupted sound today."
}

And it is rendered like below:

AI Ad copy generator

At the frontend, I am using a JS library that renders Markdown into HTML.

Conclusion

In the end, this project was a fun blend of practical AI application and lightweight backend development. It’s always exciting to see how a few smart prompts and simple tools like Flask and Gemini can come together to solve a real problem for sellers and marketers. A big part of what made this work smoothly was ScraperAPI, whose structured Amazon API made it easy to access real-time product data without worrying about IP bans or scraping hurdles. Whether you’re an Amazon seller looking to save time or a developer exploring GenAI workflows, this kind of tool shows just how accessible and powerful AI-driven automation has become.

Oh, and just so you know, I’ve been using their service whenever I need to build scalable scrapers or pull data from complex sites, especially those protected by captchas or things like Cloudflare. It’s been super reliable and saves a ton of time. If you’re interested, you can sign up using my referral link or use the promo code adnan10 to get 10% off. And if the discount doesn’t show up for some reason, just drop me an email through my site and I’ll help you out. Like always, the code is available on GitHub

 


Looking to create something similar or even more exciting? Schedule a meeting or email me at kadnan @ gmail.com.

Love What You’re Learning Here?
If my posts have sparked ideas or saved you time, consider supporting my journey of learning and sharing. Even a small contribution helps me keep this blog alive and thriving.

👉 Support My Work Here

If you like this post, then you should subscribe to my blog for future updates.

* indicates required



Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen − eleven =