Skip to content
kobiakov.dev
AI & Tools

Aimash — AI Google Ads Manager (Telegram)

A Telegram bot that manages Google Ads in plain language — but never on its own. Every budget, bid or keyword change is shown as a 'before → after' diff and runs only after you approve it. Multi-model AI, keyword research, RSA ad-copy and deep .xlsx / Google Sheets reports — a production client build with ~110k lines of Python and 2,030 automated tests behind the chat.

Timeline

2025

Role

Lead Engineer

Confirm-gate

Every change

Swappable

AI models

~21k LOC

Codebase

Engineering outcome

Ads tasks in seconds via chat · zero unapproved changes

Honest impact

Confirm-gate on every mutation · full audit trail · 2,030 tests

Problem

Running Google Ads by hand is slow and easy to get wrong, while most 'AI' tools optimise autonomously — they move real money before you can check. Advertisers want the speed of automation without handing over the keys to their budget.

The Challenge

Build an AI assistant that executes Google Ads work from a chat in natural language (RU/EN), yet keeps a human in control: every mutation must be previewed as before → after and confirmed, all secrets must stay encrypted, and nothing may ever touch a live account by accident.

The Solution

Aimash is a Python 3.12 / aiogram bot wired to the Google Ads API at MCC level. An OpenRouter LLM parses commands into typed Pydantic tool calls; reads run instantly, while every write becomes a proposal stored in PostgreSQL with a before → after diff and ✅/❌ buttons — executed only on approval and written to an audit log. It also does keyword research with AI intent-clustering, RSA ad-copy with per-element review, and deep period-over-period reports exported to Excel or Google Sheets. Even the LLM was chosen by measurement: an in-repo A/B benchmark found DeepSeek ≈ Claude on function-calling at ~13× lower cost, with Claude as automatic fallback.

Live Capabilities

See what the bot can do

A faithful recreation of the Aimash interface, built from the bot's real Telegram messages. Every change is proposed, previewed as “before → after”, and only runs after you approve it.

Telegram

aiogram 3 · RU/EN chat

LLM router

OpenRouter · DeepSeek, Claude fallback

Tool schemas

Pydantic · code-level allow-list

Confirm-gate

one-time confirmation_id · ✅ / ❌

Google Ads API

v24 · MCC level

Every request flows through typed schemas and a confirm-gate before it can touch a live account — with four standing guard-rails watching every step.

Fail-closed account allow-list 3-layer secret redaction Audit log in PostgreSQL API quota gate @ 95%

Talk to your account

Plain-language commands — stats, reports and changes, no dashboards.

A
Aimashbot · online
You
show me stats for the last 30 days
Aimash · bot
📊 Account …8841 · 30 d. Impressions: 128 400 Clicks: 5 312 (CTR 4.14%) Cost: 4 187.20 Avg. CPC: 0.79 Conversions: 213 Value: 18 940.00

Confirm-gate on every change

The AI proposes a before → after diff and waits for your ✅. Nothing moves without it.

A
Aimashbot · online
You
raise the Search Spring budget by 20%
Aimash · bot
📝 Draft change Campaign "Search Spring" — budget: 50.00 → 60.00 (+20%) Confirm?
Aimash · bot
✅ Done. Budget updated → 60.00
Confirm Cancel

AI ad copy (RSA)

Generates headlines and descriptions within Google's limits, reviewed one by one.

A
Aimashbot · online
You
/rsa Search Spring
Aimash · bot
✍️ Headline 3/8 · 27/30 · ✅ approved "Same-day flower delivery" 📋 Search Spring / Bouquets
Aimash · bot
📋 RSA curation summary Headlines approved: 5/8 Descriptions approved: 3/4 ✅ ready to create

Keyword research

Search volumes and AI intent-clusters, exportable to .xlsx.

A
Aimashbot · online
You
/keywords flower delivery
Aimash · bot
🔍 Keywords — flower delivery Ideas: 312, clusters: 7 Transactional (24) • buy flowers online — 8 100/mo • order roses delivery — 4 400/mo Commercial (18) • flower delivery near me — 6 600/mo …full table in the .xlsx

Deep reports

Period-over-period comparison, exported to Excel or Google Sheets.

A
Aimashbot · online
You
/export 30
Aimash · bot
📈 Deep report · 30 d vs prev 30 d Cost: 4 187 → 3 910 −6.6% Conv: 188 → 213 +13% CPA: 22.27 → 18.34 −18%
report.xlsxGoogle Sheets

Technical Highlights

Confirm-gate architecture: the AI proposes a before → after diff for every mutation and only executes after an explicit "yes" — no autonomous spending

Multi-model LLM via OpenRouter (DeepSeek / Claude / GPT-4o) — the model is swappable per task, never locked to one vendor

Pydantic tool schemas: the model fills typed forms that are validated before any Google Ads call — it can never invoke arbitrary SDK methods

Full audit log: who, when, what, before → after and the result of every action are persisted in PostgreSQL

Secrets encrypted at rest (Fernet); tokens never appear in code, logs or stderr; fail-closed account allow-list

Keyword research via the Keyword Plan API with AI intent-clustering, plus RSA ad-copy with per-element review and .xlsx / Google Sheets reports

System Architecture

Python 3.12 · aiogram 3.x (async bot)

OpenRouter (multi-model LLM)

Google Ads API v24 (GAQL + mutations)

SQLAlchemy + Alembic + PostgreSQL

Pydantic tool schemas (function calling)

APScheduler (reports & anomaly alerts)

openpyxl + Google Sheets API

Fernet-encrypted secrets · audit log

Docker + GitHub Actions CI (ruff · mypy · pytest)

Core Technologies

Python 3.12aiogram 3.xGoogle Ads APIOpenRouter LLMPostgreSQL
Share: