Back to Work

Creating AI sales and marketing briefing

AI & Machine Learning Marketing Automation

The need

Sales and marketing teams look at the same customers through different tools. The CRM holds accounts and deals. The marketing platform holds emails, webinars and demo requests. The data warehouse holds orders. Nobody opens all three on a Monday morning, so the most useful question, which customer should we ring first, often goes unasked.

I wanted to show that I can join those tools together and turn them into something a sales manager can act on. I set myself a brief: a weekly briefing that answers two questions.

  1. Which customers have quietly stopped ordering consumables for the devices they own?
  2. Is marketing activity leading to demo requests, and can I say so honestly?

So that I could publish all of it, everything is fictional. Veridian Optics sells ophthalmology devices (OCT scanners, phaco surgical systems, retinal cameras) and the consumables they use. Its customers are a fictional health service, the National Health Collective, and six fictional private hospital groups. The generated data hides patterns I know about, which means I can mark Claude’s work against a key it never sees.

  1. Python generators: Synthetic data created: Hidden patterns built in
  2. Raw files: One file per table: Same IDs for every account, contact and campaign (after: Synthetic data created)
  3. Answer key: Saved on my machine only: Never loaded or shown to Claude (after: Synthetic data created)
  4. Salesforce: CRM loaded: Accounts, contacts and campaigns (after: One file per table)
  5. Veridian Engage: Mock marketing platform built: Emails, webinars and demo requests (after: One file per table)
  6. BigQuery: Warehouse loaded: Nine tables of orders and activity (after: One file per table)
  7. Four fixed tools: Read-only queries, capped: Each query limited to 200 MB billed (after: Warehouse loaded)
  8. Claude: Findings written up: Uses only numbers the tools return (after: Read-only queries, capped)
  9. Scoring script: Tools checked against the key: Counts only, run on my machine (after: Read-only queries, capped)
  10. Output: Weekly briefing for sales: Markdown report with account actions (after: Findings written up)

My role

This is a solo project. I designed the data model, wrote the rules for what Claude may and may not do, ran every stage and checked the results. I built it with Claude as a coding partner: it drafted scripts, I ran them, read the errors and decided what to change. [ADD: confirm this wording, and roughly how long the build took.]

The stack, in the order the data flows through it:

  • Python generators create accounts, devices, orders, contacts and marketing activity, with hidden patterns built in.
  • Veridian Engage is a mock marketing automation platform, modelled on generic concepts (campaigns, email activity, webinars, demo requests). It is a SQLite database with a small read-only API built on FastAPI.
  • Salesforce Developer Edition holds accounts, contacts, opportunities and campaigns, loaded with the Salesforce command line tool.
  • BigQuery is the warehouse, with nine tables.
  • Claude reads from BigQuery through four fixed tools and writes the briefing.

Key decisions

1. Four fixed tools instead of free-form SQL

Claude could have written its own queries against BigQuery. I gave it four fixed, read-only tools instead:

  • find_consumables_gaps finds accounts whose devices need consumables that have not been ordered, and returns before and after order values where a clinical lead change is on record.
  • get_account_detail returns one account’s profile, devices, orders and events.
  • weekly_marketing_summary compares the latest period with the one before.
  • webinar_demo_conversion compares demo rates for webinar attendees, no-shows and contacts who never registered.

I chose this because fixed tools are repeatable (the same question runs the same query), checkable (I can score each tool on its own) and safe (read-only, and every query is capped at 200 MB billed). The cost is flexibility: a new kind of question needs a new tool. For a briefing that goes to managers every week, I took repeatable over flexible.

This is what a run looks like in the terminal:

[tool call] find_consumables_gaps {"months_without_orders": 6, "limit": 300}
[tool call] weekly_marketing_summary {"period_days": 28}
[tool call] webinar_demo_conversion {}
[tool call] get_account_detail {"account_id": "ACC-0041"}

[GitHub embed 1: the find_consumables_gaps function in src/agent/tools.py. See the publishing pack below for how to embed it.]

2. Score the AI against an answer key it never sees

The generator hides three kinds of account: those that lapsed after a clinical lead change, those with a consumables gap and no lead change, and healthy decoys, including accounts that had a lead change and kept ordering. The answer key lives only on my machine. It is git-ignored, never loaded into BigQuery and never shown to Claude. A small scoring script prints counts only.

At a six month threshold the consumables tool flags 96 accounts:

What the account really isFlagged
Lapsed after a clinical lead change34
Consumables gap, no lead change50
Healthy account flagged wrongly12

That is about 88% precision and about 78% recall. The lead change date separates the first two stories cleanly, and the decoys are not flagged. It is not perfect, and the README says so.

[Image 2: terminal screenshot of the scoring script output, with no account IDs showing.]

3. One set of IDs across three systems

Every account, contact and campaign carries the same ID in Salesforce, the marketing platform and BigQuery. In Salesforce those IDs are external ID fields. That means ACC-0231 is the same hospital everywhere, most loads can be re-run safely as upserts, and any number Claude quotes can be traced back to a record.

Salesforce Developer Edition allows 5 MB of data, so I chose carefully what to load. It holds the 900 contacts that sit in the marketing platform, plus 32 campaigns (26 email and 6 webinar) with 490 webinar members, and ends at 3.7 MB, or 74% of the limit.

[Image 3: the Salesforce Campaigns list view. Image 4: one webinar campaign showing its members and their Registered or Attended status.]

4. Tell Claude what to do when the data runs out

The system prompt tells Claude to use only numbers from the tools, to mark inferences as inferences, and to state the date the data runs to. The weekly report prompt adds rules like these:

Where you describe an account as still ordering, give the date of its last order. Do not call missing order history a data error unless the tools show evidence of one.
Use only numbers from the tools. Mark inferences as inferences. Do not recommend actions that need data the tools do not return, such as lists of contacts who did not click or who did not attend.

Each of those lines exists because an earlier version got it wrong. I come back to that below.

[GitHub embed 2: the PROMPT text in src/agent/monday_report.py.]

The output

One command writes the briefing as a Markdown file and costs a few cents in Claude usage:

python -m src.agent.monday_report

The briefing opens with a two sentence headline, then three sections: consumables, marketing and three actions for the week. In consumables, it says 96 accounts have a gap at six months, 34 with a recorded lead change and 62 without. It then names eight accounts to contact: the five lead-change accounts with the biggest fall in monthly order value, and the three accounts with no lead change that have the most devices with a gap. Each row carries a suggested first question for the call.

AccountWhat changedFirst question
Lisburn Lagan Hospital (ACC-0231)Lead change 11 March 2026. Monthly value fell from £1,121 to £254. 2 of 4 devices have a Surgical Packs gap.Who now places Surgical Pack orders, and why have they stopped for those two devices?
Llandudno Conwy Hospital (ACC-0055)Lead change 22 July 2025. Monthly value fell from £844 to £64. 4 of 5 devices have a gap.Has purchasing moved to a different supplier or route since the new lead arrived?
Northumbria Coastal Hospital (ACC-0263)No lead change. All 5 devices have a gap. Last order 15 July 2025.Is anyone still responsible for consumables at this site?

The report also found 16 accounts that own devices but have never ordered consumables. One example is a hospital that has been a customer since 2018, with devices installed in 2020 and 2021 and no orders on record. That looks like a sales opportunity more than a data problem, and the report says so.

The marketing section compares the latest four weeks with the four before. Demo requests fell from 12 to 7 while email volume halved, and the report describes that as a fall in sends, not a failure of the content. Then it gives the webinar result:

SegmentContactsRequested a demoDemo rate
Attended a webinar2326025.9%
Registered but did not attend134118.2%
Never registered516448.5%

Attendees request demos about three times as often as other contacts, and registering without attending makes no difference. The report is clear that this is an association, not a cause. I checked one more thing the tool cannot: all 60 attendee demo requests came after the contact’s first webinar registration, so the demo request did not come first.

[Image 5: the finished briefing, previewed as a formatted page. Image 6: a terminal showing the command and the saved file path.]

[GitHub embed 3: the sample briefing in the reports folder.]

What I learned

1. A quiet limit changes the answer. Early on, any tool result over 40,000 characters was cut off without a warning. Claude noticed it was missing data and switched from a six month threshold to a 12 month one to cope, which changed every number in the report. The tool now returns an explicit “too large, ask for fewer rows” message, and the prompt forbids changing the threshold. Failures in an AI workflow should be loud.

2. My own instruction was the bug. The first report called the 16 never-ordered accounts probable false alarms that needed a data check. That was in my prompt. I opened the raw tool output for one of them and found a customer since 2018 with devices installed in 2020 and 2021 and no orders. The tool was right and my instruction was wrong. I rewrote the prompt, and the accounts now appear as an opportunity.

3. Give the model numbers, not verdicts. A flag called “ordered after lead change” led Claude to say that lead changes do not explain everything. The flag was misleading, not the data. I replaced it with the average monthly order value before and after the lead change, and the story became clear.

4. Check what the AI cannot, and say what the data is. The webinar tool could not tell whether the demo request or the webinar came first, so I checked that separately on the raw data. I also built this dataset with the webinar effect inside it. So the project does not show that webinars drive demos. It shows that the tools find the effect, and describe it without overclaiming.

Try it yourself

The code, the Salesforce setup, the data generators and a sample briefing are in the repository: github.com/ollygathercole/marketing-automation-demo. The README has the run order, the evaluation results and the known limitations.

The short version:

python -m src.generators.accounts
python -m src.engage.build_database
python -m src.loaders.bigquery_load
python -m src.agent.monday_report

The full list of generator steps is in the README. You will need your own Google Cloud project and Anthropic API key, and the Salesforce part is optional. BigQuery sandbox tables expire after 60 days, so the README also shows how to rebuild them in one command.

Everything in the project is fictional. If you have any feedback or want to discuss the project feel free to reach out to me below