How to retrieve a random entry from data source using Zapier automation

I’m trying to create a Zapier workflow that automatically sends out emails with random content. The email content needs to be pulled randomly from a database or storage system that can handle HTML formatting. I’ve been considering using Airtable or maybe a simple database as the source.

The main challenge I’m facing is figuring out how to configure Zapier to fetch a random row or entry from my data source instead of always getting the same record or the most recent one.

Has anyone managed to set up something like this before? What approach did you use to make Zapier select random records from your data source?

i did sumthng similar with googl sheets! just added a rand num col with =RAND() and then used zapier’s “lookup spreadsheet row” to fetch random rows. it works well but b careful of getting duplicates!

Here’s what worked great for me: Webhooks by Zapier + a simple PHP script on shared hosting. The script hits a MySQL database, runs SELECT with ORDER BY RAND() to grab a random record, then sends it back as JSON to Zapier. You get full control over the randomization and HTML content works perfectly since you can structure the JSON however you want. Takes more setup than Airtable but way cheaper if you’ve got tons of records and need lots of random pulls. Just check that your host allows external API calls.

Airtable + Code by Zapier works great for this. I built something similar last year. The most reliable setup I found was using Airtable as your data source with Zapier’s Code step. In the code, I generate a random number based on total records, then use that to pull a specific record through Airtable’s API. Gets you truly random picks without duplicates in the same run. HTML formatting from Airtable fields carries over to email templates no problem. Pro tip: if your database is huge, cache the total record count so you don’t hit API limits.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.