/article

How IĀ built a marketing AIĀ agent in Cursor

AI agents are everywhere right now. When I scroll through my feed on LinkedIn or X, it feels like everyone is talking about them, how agents are set to change the way we work, the way we sell, and the way we make decisions.

I don’t doubt for a second that they will.

But there’s something missing in the feed: concrete examples.

How do you actually build one? What should it do? What data should it interpret? How do you write the prompt?

Few show what they’ve actually built or how they acutally use them.

So I decided to build my own AI agent. Not by using an off-the-shelf no-code tool that connects APIs with ā€œdrag and drop,ā€ but by building one from scratch.

If you want to know how I built it and what it does. Then this article is for you.

What does the agent do?

The agent fetches data from the website of our sports app HurryUp. I wanted to pull in traffic and conversion data so we could analyze how visitors are using the site. Based on that analysis, the agent would give us suggestions on what to do next or flag anything that needs a closer look.

To know what to build I needed to answer a few questions for myself.

  • What problem is the agent solving?
  • What data should it collect and analyze?
  • What should the report look like?
  • What’s the ideal flow?
  • What integrations do we need?
  • Which language model should we use?

Once these were clear, I could start building.

The agent I built does six things:

  1. Collects data
  2. Organizes data
  3. Runs an AI analysis
  4. Generates insights and actions
  5. Creates a report
  6. Sends it to Slack

Building an AI agent in Cursor

I built the agent with TypeScript in Cursor (got to love Cursor). The structure I’ve set up is designed to scale easily and handle multi-site setups and multiple report types without requiring changes to the core structure.

Simply put: you can connect additional analytics tools, websites, and report types with just minor adjustments in the code. Reports can be generated manually via your editor’s terminal or run them automatically at set intervals using GitHub Actions.

Integrations I use:

  • An analytics tool API to fetch data
  • A language model API to interpret and formulate insights (we chose ChatGPT)
  • An integration with a communication tool to send the report to the team (we chose Slack)

Tools I use:

  • Cursor
  • GitHub

Functionality:

  • Runs reports automatically at set times
  • Can connect to multiple analytics tools
  • Compares data over time (week-over-week, month-over-month, year-over-year)
  • Scales from one site to many without changing the core structure
  • Can send reports to multiple channels (Slack, email, MS Teams, etc.)
  • Allows you to add new metrics or change the format without rebuilding the system
  • Supports multiple report types

The output (report)

The structure is designed to give a clear summary of what’s happening on the site. The idea is that every Monday on the stand up meeting you can quickly read the report and decide if anything requires further attention.

The report is divided into three fixed sections:

  1. A short text based analysis summarizing traffic, traffic sources, countries, and conversions
  2. A data driven overview with key metrics, device usage, geographic distribution, and campaign results
  3. A set of action suggestions, or a flag if something needs a closer look, always based on actual numbers

Version 1.0

This is the first version of the agent. It’s simple but powerful, solving one clear task. I plan to develop it further with more advanced functionality over time.

For example, you could add another layer of analytics to have it analyze product data, such as retention rate, churn rate, and MAU. You could also connect ad analytics (Meta, Google Ads) and email marketing stats. Maybe the agent should store reports for you in Google Drive. Or even optimize the ads based on the data it collects.

Endless of possibilities! But what it should do next is something I’ll keep exploring.

Saves two workweeks per year

Even though we have only just started using the agent (at Good Morning), you can easily calculate the savings.

What used to take around an hour a week to pull data from our analytics tool, compare it to the previous week, and write a summary is now done automatically by the agent.

That is approximately 47 hours a year, nearly a full workweek.

Add a monthly report and it doubles to 94 hours, over two workweeks that can now be spent on development instead.

Does this agent replace your entire analytics tool? No, you still need to dive into the numbers yourself. But the agent points you in the right direction.

This is not a big AI solution. I would rather call it a lightweight agent. But that is exactly what makes it so interesting. You do not always need to build large and complex systems.

Sometimes a small agent that saves time and lets you focus on what matters most is enough. To build a small agent like this is an excellent example on how you can already today build your own agents without heavy investments. And it is an exciting way to explore how far it can go.

How far I can actually take it is something we will find out in version 2.0.

Thanks for reading. /Marcus Strömberg