Use Case
Generate Product Videos from Your Shopify Webhook
Register a product.create webhook in Shopify, receive the payload, and call the agent-media API to generate a talking-head video for each new product automatically. TypeScript SDK, Python client, and CLI supported. Read the docs.
Webhook Handler: Next.js / Express
Receive Shopify products/create events and trigger video generation. This example uses a Next.js API route, but any framework that handles POST requests works.
// Verify the Shopify HMAC header in production
import { AgentMedia } from "agent-media";
import { NextResponse } from "next/server";
const client = new AgentMedia( process.env.AGENT_MEDIA_API_KEY!);
export async function POST(req: Request) {
const product = await req.json();
const video = await client.videos.create({
script: product.body_html,
actor: "emma",
brollImages: [product.image?.src],
style: "clean",
duration: 10,
template: "product-demo",
});
return NextResponse.json({ videoId: video.id });
}
TypeScript SDK: Generate a Product Demo Video
Use the SDK directly when you need more control -- poll for completion, attach metadata, or upload the result back to Shopify via the Admin API.
import { AgentMedia } from "agent-media";
const client = new AgentMedia( process.env.AGENT_MEDIA_API_KEY!);
const video = await client.videos.create({
aiScript: "Organic bamboo cutting board, 14x10 inches, knife-friendly surface",
template: "product-demo",
actor: "emma",
brollImages: [ "https://cdn.shopify.com/s/.../bamboo-board.jpg"],
style: "clean",
duration: 10,
});
// Poll until ready
const result = await client.videos.wait(video.id);
console.log(result.url); // https://media.agent-media.ai/videos/abc123.mp4
Python: Batch Process Your Catalog
Pull products from the Shopify Admin API and generate videos for every SKU in a single script.
import shopify
import agent_media
client = agent_media.Client(api_key=os.environ[ "AGENT_MEDIA_API_KEY"])
products = shopify.Product.find()
for product in products:
video = client.videos.create(
ai_script=product.body_html,
template="product-demo",
actor="emma",
broll_images=[product.image.src],
style="clean",
duration=10,
)
print(f"{product.title}: {video.id}")
CLI: One-Off or Scripted
Generate a single product video from the command line, or wrap it in a shell loop for quick batch runs.
# Generate a single product video
$ agent-media video create \
--ai-script "Organic bamboo cutting board, 14x10 inches, knife-friendly surface" \
--template product-demo \
--actor emma \
--broll-images "https://cdn.shopify.com/s/.../bamboo-board.jpg" \
--style clean \
--duration 10 --sync
# Batch: loop over a CSV of products
$ while IFS=, read -r name desc img; do
agent-media video create --ai-script "$desc" --actor emma \
--broll-images "$img" --template product-demo --style clean
done < products.csv
Set Up the Webhook in Shopify Admin
Register the webhook so Shopify sends product data to your endpoint automatically.
Go to Settings → Notifications → Webhooks
In your Shopify admin, navigate to Settings → Notifications and scroll to the Webhooks section at the bottom.
Create a webhook for Product creation
Click Create webhook. Set the event to Product creation, format to JSON, and enter your endpoint URL (e.g. https://yourapp.com/api/shopify/webhook).
Verify the HMAC signature
Shopify signs every webhook with an HMAC header. Verify it against your app's secret to ensure the payload is authentic. See the docs for a verification helper.
Test with a new product
Create a test product in Shopify. Your webhook fires, agent-media generates the video, and you get the video URL back. Poll client.videos.get(videoId) or use the --sync flag in the CLI to wait for completion.
Why Developers Choose agent-media
Webhook-native architecture
Receive product events, call the API, get a video URL. Fits into any event-driven pipeline without custom infrastructure.
TypeScript + Python SDKs
Typed clients with auto-completion. Create videos, poll status, and download results in a few lines of code.
AI script generation
Pass raw product descriptions. The API generates a natural demo script using the product-demo template. No copywriting needed.
Batch via CLI or API
Loop over a product CSV or paginate through the Shopify Admin API. Generate videos for the entire catalog programmatically.
Sync and async modes
Use --sync in the CLI to block until the video is ready, or poll the status endpoint in your application code.
Product image as B-roll
Pass your Shopify CDN image URL. The pipeline animates it as a cutaway scene so viewers see the actual product.
Related Pages
Last updated: April 2026