Case study · Applied AI

Audience Craft AI: A Text-to-SQL AI System for Ad Campaign Targeting

Turning a plain-language campaign brief into the exact audience segment to target — then using that segment's matched IDs to launch the campaign across Meta, TikTok, and Google.

By Sandaruwan Jayasundara — Senior Software Engineer | AI Engineer

The problem

Running a paid ad campaign starts with a targeting question: who exactly should see this? The answer usually lives inside a large, proprietary audience dataset — but getting to it means someone writing precise SQL against a complex schema, or a media buyer waiting on a data team every time a brief changes. That gap between "here's what the campaign needs" and "here's the exact segment to target" is where campaigns lose time and accuracy.

Audience Craft AI was built to close that gap: a text-to-SQL AI layer that takes a campaign brief in plain language and finds the most accurate targeting segment directly from the underlying dataset — no manual query writing required.

How it works

1. Campaign brief → structured query

A campaign brief ("target users likely to convert on outdoor gear in urban Australia, age 25–40") is parsed and translated into a validated SQL query against the audience dataset's schema, rather than a freeform prompt sent straight to a database. The text-to-SQL layer is constrained to the actual schema — table names, column types, valid value ranges — so it can't produce a query that references data that doesn't exist.

2. Finding the most accurate segment

The generated query runs against the proprietary dataset to surface the audience segment that best matches the brief's targeting criteria — the people most likely to be relevant to that specific campaign, not just a broad demographic bucket.

3. From segment to live campaign

Once the segment is identified, Audience Craft AI uses the associated client MUIDs to build and launch a targeted campaign directly on the ad platform — Meta, TikTok, Google, or others — connecting the targeting decision to campaign creation without a manual handoff in between.

The hard part of text-to-SQL for ad-tech isn't generating a plausible query — it's constraining generation to a schema precise enough that "plausible" and "correct" are the same thing.

Technical approach

Why this matters

Precision targeting is only useful if it's fast enough to act on. By collapsing "brief → query → segment → campaign" into one AI-assisted flow, Audience Craft AI removes the dependency on a data specialist for every targeting change, while keeping the underlying query generation constrained and auditable rather than an opaque black box.

Related work

This project sits alongside my broader applied AI work — see building production RAG systems with LangChain for a related look at grounding AI systems in real, structured data rather than open-ended generation.

I'm Sandaruwan Jayasundara — Senior Software Engineer | AI Engineer. Explore AI engineering services or get in touch to discuss a similar system.