← Catalog

AI advertising campaign analyst: automatic bid optimization in Facebook and Google Ads
8 text .md documents with descriptions of the architecture, code, and instructions. Scripts and configuration files are provided inside the .md as code blocks (Python, Node.js, SQL, Dockerfile, .env, config.json).

AI advertising campaign analyst: automatic bid optimization in Facebook and Google Ads

Version 1.0.0 Updated: 2026-09-13 Quality: 82/100

A ready-made system of 8 modules: it collects data from the Facebook Marketing API and Google Ads API, analyzes it via an LLM, suggests optimizations, and automatically changes bids and budgets. A web dashboard with one-click change confirmation.

📁 What is inside (ZIP, 9 files)
  • 01_architecture_overview.md
  • 02_connectors_setup.md
  • 03_data_collection_pipeline.md
  • 04_llm_analysis_engine.md
  • 05_bid_management_automation.md
  • 06_web_dashboard.md
  • 07_deployment_and_scaling.md
  • 08_roi_optimization_playbook.md
  • README.md

Problem

Manual management of bids and budgets in Facebook and Google Ads eats up hours every week. Metrics are scattered across two accounts, decisions are made intuitively, and ChatGPT has no access to ad platform APIs and cannot make changes. As a result, budget is wasted on weak campaigns, while successful ones are not scaled in time.

Solution

The system automatically collects data from the Facebook Marketing API and Google Ads API on a schedule, normalizes the metrics into a single schema, and passes them to the LLM analyst. The LLM generates recommendations, the validator turns them into API commands taking into account your thresholds and limits, and the execution module changes bids, budgets, and campaign statuses. The web dashboard displays everything in real time and allows you to confirm changes manually.

More details

This is not a prompt pack or a guide, but a working system made up of 8 interconnected modules. It connects to the Facebook Marketing API and Google Ads API via OAuth 2.0, pulls campaigns, ad sets, ads, and key metrics (CTR, CPC, CPM, conversions, spend), normalizes them into a single schema, and stores them in a local database (SQLite or PostgreSQL). Then the LLM analyst kicks in: based on the normalized metrics, it generates structured recommendations — what to scale, what to turn off, where to lower or raise the bid. The LLM recommendations go through validation against your thresholds and rules (for example, lowering the bid when CTR < 1%), after which they are turned into API commands: update_bid, update_budget, pause_campaign, enable_campaign. The safe change-application module caps the maximum budget increase, logs every action, and can roll back failures. All of this is visible in a mini web dashboard: campaign tables, ROI charts, a list of recommendations, and manual approval buttons. Deployment is described for Docker and cron: container, environment variables, monitoring, alerts, data backups, and a security checklist. The system scales to multiple ad accounts and both platforms simultaneously. Additionally included is an ROI playbook with A/B testing methodology, budget reallocation, and client report templates. Who it's for: AI-automation micro-agencies, info-producers, and marketers who run ads on Facebook and Google and want to automate the bidding routine without hiring a dedicated analyst. Stack: Python + FastAPI/Flask + SQLite/PostgreSQL + OpenAI GPT-4 or Anthropic Claude + Facebook Marketing API + Google Ads API.

Features

  • Connecting to the Facebook Marketing API and Google Ads API via OAuth 2.0 with handling of authorization errors and rate limits
  • Collecting campaigns, ad groups, ads, and metrics: CTR, CPC, CPM, conversions, spend
  • Normalizing data from the two platforms into a unified schema and storing it in SQLite or PostgreSQL
  • A cron-based task scheduler for regular data collection
  • An LLM analyst based on OpenAI GPT-4, Anthropic Claude, or a local model that generates recommendations
  • Validating LLM responses and converting them into structured commands for the API
  • Configuring thresholds and rules (for example, lowering the bid when CTR < 1%)
  • Automatically changing bids and budgets via the API: update_bid, update_budget, pause_campaign, enable_campaign
  • Safely applying changes: limits, logging, rollback on failures
  • A web dashboard with campaign tables, ROI charts, a list of recommendations, and confirmation buttons
  • Authentication in the dashboard, configuring thresholds, exporting reports
  • Docker deployment, monitoring, alerts, backups, and a security checklist
  • ROI playbook: A/B testing strategies, budget reallocation, client report templates

What you get

  • 01_architecture_overview.md — system architecture: data flows from the Facebook Ads API and Google Ads API to the LLM analyst and back, component descriptions, environment requirements
  • 02_connectors_setup.md — step-by-step setup of connections to the Facebook Marketing API and Google Ads API: access token, OAuth 2.0, account selection, examples of .env and config.json, connection test scripts
  • 03_data_collection_pipeline.md — implementation of data collection: API requests, normalization of metrics into a unified schema, storage in SQLite/PostgreSQL, cron scheduler
  • 04_llm_analysis_engine.md — the analysis core: preparing prompts for the LLM, generating recommendations, validating responses, converting them into API commands, configuring thresholds and rules
  • 05_bid_management_automation.md — module for automatic changes to bids and budgets: update_bid, update_budget, pause_campaign, enable_campaign, limits, logging, rollback on failures, code examples
  • 06_web_dashboard.md — mini web application (FastAPI/Flask + HTML/JS) for visualization: campaign tables, ROI charts, list of recommendations, confirmation buttons, authentication, report export
  • 07_deployment_and_scaling.md — deployment guide: Docker container, environment variables, cron, monitoring, alerts, scaling to multiple accounts, backup, security checklist
  • 08_roi_optimization_playbook.md — methodology for improving ROI: A/B testing strategies, budget reallocation, scenarios for declining conversions, client report templates, hypothesis generation via LLM

Installation guide

1. Review 01_architecture_overview.md to understand the data flow diagram and environment requirements. 2. Following the instructions in 02_connectors_setup.md, obtain an access token and configure OAuth 2.0 for the Facebook Marketing API and Google Ads API, fill in .env and config.json. 3. Deploy data collection according to 03_data_collection_pipeline.md: create a SQLite or PostgreSQL database, run the collection scripts, and set up cron. 4. Configure the LLM analyst according to 04_llm_analysis_engine.md: specify the OpenAI or Anthropic API key, set thresholds and rules. 5. Implement the bid management module according to 05_bid_management_automation.md with limits and logging. 6. Launch the web dashboard according to 06_web_dashboard.md locally or on a server. 7. Deploy the system in Docker according to 07_deployment_and_scaling.md and set up monitoring. 8. Use 08_roi_optimization_playbook.md for optimization and reporting strategies.

Requirements

Python 3.10+ or Node.js 18+, SQLite or PostgreSQL, access to the Facebook Marketing API and Google Ads API with campaign management permissions, OAuth 2.0 tokens, an OpenAI GPT-4 or Anthropic Claude API key (or a local LLM), Docker (for deployment), cron, basic command-line and API skills.

Options and pricing

Choose the level that suits you:

  • Basic — $35 · The main set of product files.
  • Standard — $59 · Full set + implementation guide.
  • Extended — $94 · Everything from Standard + extended materials and updates.

Frequently asked questions

What is included?

A ready-made system of 8 modules: it collects data from the Facebook Marketing API and Google Ads API, analyzes it via an LLM, suggests optimizations, and automatically changes bids and budgets. A web dashboard with one-click change confirmation.

In what format will I receive the files?

After payment you get a secure link and a ZIP archive with all materials. The link is shown on the order page and available via the Telegram bot.

How long is the download link valid?

The link is active for 24 hours, up to 5 downloads.

Do I need special skills?

The product is designed for entrepreneurs and specialists. A step-by-step guide is included; no programming skills required.

Can I get a refund?

For refunds, contact support: [email protected].

See also