What inspired us

FlexiWork is a workforce infrastructure platform for UK shift-based businesses — hospitality, F&B, retail, events. We're launching now, which means we need leads. Not scraped lists. Not cold databases. Signal-based leads — businesses that are actively feeling the pain FlexiWork solves.

The insight was simple: any UK hospitality employer posting a zero-hours or casual worker job right now is 4 months away from an ERA 2025 compliance problem they probably haven't planned for. Shift notice rights come into force October 2026. Guaranteed hours follow in 2027. Every one of those job postings is a buying signal.

We built an agent to find them.


What we built

An autonomous GTM lead scoring agent that runs every 60 seconds without any human input:

  1. Gemini 2.0 Flash searches the web for UK hospitality, F&B, retail, and events businesses actively hiring zero-hours or casual workers
  2. Enriches each company — sector, number of sites, review volume, website
  3. Discovers the decision maker — General Manager, HR Manager, or Owner — via Gemini-grounded LinkedIn and website search
  4. Scores leads in ClickHouse using weighted SQL multipliers:

$$\text{score} = \sum w_i \times m_{\text{multi-site}} \times m_{\text{reviews}} \times m_{\text{sector}} \times m_{\text{DM found}}$$

Where:

  • $w_i$ = signal weight (zero-hours hire = 10, rota manager hire = 9)
  • $m_{\text{multi-site}} = 1.5$ if 2+ locations confirmed
  • $m_{\text{reviews}} = 1.2$ if 50+ reviews (proven operating business)
  • $m_{\text{sector}} = 1.3$ if hospitality or F&B
  • $m_{\text{DM found}} = 1.4$ if decision maker identified
  1. Generates personalised outreach via Gemini — ERA 2025 framed, British tone, addressed to the specific decision maker by name
  2. Logs every decision to Langfuse — full trace from search query to scored lead to generated email

A Next.js 15 live dashboard shows everything in real time: stat cards pulling from ClickHouse, ranked lead cards with expandable DM details, a live signal feed, and a Langfuse trace panel showing the agent's reasoning chain.


How we built it

Stack:

  • Gemini 2.0 Flash — web search grounding, company enrichment, decision maker discovery, email generation
  • ClickHouse Cloud — signal storage, real-time lead scoring, sub-second SQL aggregations across all detected companies
  • Langfuse — full LLM observability, every agent step traced and logged
  • Next.js 15 — live dashboard with 15-second auto-refresh
  • Python asyncio — parallel search queries, async enrichment loop

The agent started with Tavily for search — but we ran out of credits mid-hackathon. We switched entirely to Gemini's native Google Search grounding tool, which turned out to be cleaner: one API, one key, search and generation in the same call.


Challenges we faced

Job boards as companies. Gemini kept returning Caterer.com, Indeed, and Reed as "employers" because those sites dominate hospitality job search results. We built a two-layer filter: a blocklist of known job board domains plus a Gemini prompt that explicitly instructs it to return only real trading names. Real leads started appearing from cycle 3 onwards.

Deprecated Gemini SDK. google.generativeai was deprecated mid-build. Switched to google.genai with the new client pattern — 30 minutes of unexpected debugging.

ClickHouse host format. The connection string expected a bare hostname, not a URL. https://host:8443 became host — simple fix, non-obvious error message.

Decision maker quality. The agent sometimes returns the company name instead of a person's name when it can't find an individual. We added confidence scoring (0.4–0.7) and filter at 0.5 threshold so only credible DMs surface in the dashboard.


What we learned

ClickHouse is genuinely fast for this use case — scoring multipliers across hundreds of companies in a single SQL aggregation, sub-second, is something a traditional Postgres setup would struggle with at scale.

Langfuse transforms an agent from a black box into something you can actually debug and demonstrate. Seeing the full trace — search query, Gemini response, enrichment, score, email — in one timeline made the demo infinitely more compelling than showing a terminal.

And Gemini's Google Search grounding is underrated. No separate search API needed. The model searches, reasons about what it found, and returns structured JSON — in one call.


What's next

This agent runs in production for FlexiWork's GTM from Monday. Every Friday morning: review the top 10 leads, send the emails. The next version adds a direct Brevo integration so approved emails send automatically — fully closing the loop from signal detection to outreach without any human in the middle.

Built With

Share this project:

Updates