DEV Community

AI Builders
AI Builders

Posted on

How I Built an AI Agent That Emails Me a Competitor Report Every Morning

How I Built an AI Agent That Emails Me a Competitor Report Every Morning

Last month I got tired of manually checking 5 competitors every morning. So I built an agent that does it for me — and emails me the report before my coffee.

Here's the full build, start to finish. No fluff.

The architecture (3 pieces)

[ Scheduler ] -> [ Agent (research) ] -> [ Email Sender ]
  cron: 6am                                (report)
Enter fullscreen mode Exit fullscreen mode

The agent itself uses the classic recipe: LLM + Tools + Memory.

Step 1: The tools

The agent needs two tools:

  1. Search — find what competitors published/launched
  2. Scrape — read the actual pages
from fastmcp import FastMCP

mcp = FastMCP("competitor-intel")

@mcp.tool()
def search_web(query: str) -> list[dict]:
    """Search the web and return top results."""
    # SerpAPI / Tavily / whatever you use
    ...

@mcp.tool()
def fetch_page(url: str) -> str:
    """Fetch and extract text from a URL."""
    ...
Enter fullscreen mode Exit fullscreen mode

Step 2: The system prompt

This is where most people fail — they write a vague prompt and get vague results. Mine is specific:

You are a competitive intelligence analyst.

For EACH competitor in the list:
1. Search for recent news, product launches, and pricing changes
2. Visit the top 2 relevant pages and extract specifics
3. Note: what changed, why it matters, what we should do

Output format (markdown):
## Competitor: {name}
**What changed:** ...
**Why it matters:** ...
**Recommended action:** ...

If a competitor has nothing new, say "No significant changes."
NEVER invent data. If search returns nothing, say so.
Enter fullscreen mode Exit fullscreen mode

Step 3: The agent loop

from langchain_openai import ChatOpenAI
from langchain.agents import create_tool_calling_agent, AgentExecutor

model = ChatOpenAI(model="gpt-4o-mini")  # cheap & fast
tools = [search_web, fetch_page]
agent = create_tool_calling_agent(model, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)

competitors = ["acme.com", "rival.io", "theotherone.dev"]
report = executor.invoke({
    "input": f"Analyze these competitors: {competitors}"
})["output"]
Enter fullscreen mode Exit fullscreen mode

Step 4: The email

import smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg["Subject"] = "Daily Competitor Report"
msg["From"] = "agent@mycompany.com"
msg["To"] = "me@mycompany.com"
msg.set_content(report)

with smtplib.SMTP("smtp.gmail.com", 587) as s:
    s.starttls()
    s.login("agent@mycompany.com", "app-password")
    s.send_message(msg)
Enter fullscreen mode Exit fullscreen mode

Step 5: Schedule it

A simple cron job:

0 6 * * *  /usr/bin/python3 /home/me/competitor_intel/main.py
Enter fullscreen mode Exit fullscreen mode

That's it. Every morning at 6am, the agent researches 5 competitors, writes a structured report, and emails it to me. Total time invested: ~3 hours. Total time saved: 30 minutes every single day.

What I'd do differently

  1. Add a "last seen" memory — so the agent only reports new changes, not re-reports the same launch 3 days in a row
  2. Human-in-the-loop for actions — let it draft responses to competitors, but require my approval before sending
  3. Structured output — parse the report as JSON so it can feed a dashboard, not just an email

The business angle

I built this for myself. Then I realized agencies charge $500-$2,000/month for exactly this service. That's the difference between a demo and a product: it runs unattended, produces structured value, and someone would pay for it.

I collected 10 more blueprints like this (inbox triage, invoice chasing, SEO auditing, lead qualification...) plus the architecture patterns and monetization playbook into a field guide:

AI Agents & Automation Playbook - https://helmadin.gumroad.com/l/ai-agents-playbook

Launch price $11.99 (code LAUNCH11) + 12 months of free updates + bonus pack of production prompts.

This was Chapter 6 of the playbook, abridged. If this helped - the book goes deeper into evals, observability, and selling these systems.


🌐 More free tutorials, the newsletter and all products: https://hirara-hermes.github.io/

Top comments (0)