AUTOMATION GUIDE

Audit every Meta ad.
Every morning.

Build a daily n8n audit that checks seven-day performance, groups what needs attention, and sends the decisions to Slack.

It recommends. You decide.The workflow never pauses or edits an ad by itself.
METRICS → DAILY DECISIONS
7-day ad data
CPA ₹1,840CTR 1.9%Spend ₹42k
# ad-ops
DAILY AD BRAIN 🏆 Winners 3 🚨 Dead on arrival 2 Spend skews 1 🍂 Winner decay 2
Metan8nSlack
Impact5 issue types1× daily action list
01The idea

An extra pair of eyes
on your ad account.

Every morning, the workflow reads seven days of Meta results and sorts the ads into five useful decision buckets. Your team gets the short version in Slack instead of rebuilding the same report.

🏆WinnersGood CPA + enough purchases🚨Dead on arrivalEnough spend, weak resultSpend skewsOne weak ad hogs budget📉Five-day missesRepeated underperformance🍂Winner decayCPA or CTR gets worse
Your rules, not universal truths: Target CPA, test spend, currency, naming clues, and decay thresholds in the supplied workflow are examples. Replace them before the first run.
02Watch it work

From raw Meta data
to a morning action list.

Follow one daily audit from the 4 AM trigger to a human-reviewed Slack report.

Step 1 of 6
04:00Every day
n8n

The daily check starts

At your chosen time, the audit wakes up by itself.

Moves forwardDaily run
03The steps

What the daily branch does.

01

The audit starts every day

At your chosen time, n8n starts a fresh performance check.

02

Meta sends seven days of results

The workflow asks for spend, clicks, impressions, and purchases for every ad.

03

Muted ads are removed

Any ad or ad set on your ignore list is skipped before the rules run.

04

Five rule groups inspect the data

The workflow finds winners, early failures, spend skews, five-day misses, and tired winners.

05

Slack gets the decisions

One readable report tells the team what deserves attention and why.

Two triggers, two jobs: The Schedule Trigger runs this daily audit. The separate Webhook waits for optional Slack commands. You can use the audit without enabling the Webhook branch.
04Build it

Build the daily audit first.

Finish and test the card in front of you. Leave the optional Slack command branch disabled for now.

NEW N8N WORKFLOW

Start one blank workflow and use Import from URL. The import contains both branches, but its optional add-on arrives disabled.

Step 1 of 10
01
DECISION RULES

Write down “good” and “bad”

Do this before touching n8n. The example workflow assumes ₹2,000 target CPA, ₹4,000 minimum test budget, and 60% spend skew.

Target CPA your efficient purchase costTest spend enough money before judgingSpend skew too much budget on one adWinner minimum purchases + good CPADecay CPA misses or CTR drop
Be boringly specificUse one currency and one purchase definition. Write the numbers your team already uses—not the examples in this file.
02
CONNECT META

Give n8n read-only ad access

The daily branch needs Meta next, so connect it here.

  1. Create or choose a Meta developer app connected to the Business Portfolio that owns the ad account.
  2. Use a token with ads_read. This audit does not need permission to edit ads.
  3. In n8n, create a Facebook Graph API credential and test one small read.
Connected whenA read-only request can see the intended ad account without placing the token inside the URL.
03
DAILY AUDITOR

Import Meta Ad Brain

NEW N8N WORKFLOW

In n8n, create a blank workflow. Open its menu, choose Import from URL, and paste the hosted URL.

HOSTED WORKFLOW URL/downloads/workflows/meta-ad-brain.json
Safe importThe workflow is inactive. The Slack STOP-command branch is disabled node by node until section 05 is completed.
04
DAILY CLOCK

Choose the audit time

Open Schedule Trigger. The example wakes at 4:00 AM.

  1. Choose a time after Meta’s reporting day has had time to settle.
  2. Open workflow settings and confirm the timezone. “4 AM” means nothing without it.
  3. Keep one run per day while testing.
Quick checkTemporarily schedule a near-future run, confirm it starts once, then restore the real daily time.
05
META INSIGHTS REQUEST

Point it at your ad account

Open GET Facebook Data and replace every placeholder.

  1. Select the Meta credential from card 02.
  2. Use a currently supported Graph API version and your act_AD_ACCOUNT_ID.
  3. Keep level ad, daily time increments, and the last-seven-days date preset.
  4. Keep only the fields the cleaner uses: ad/ad-set IDs and names, spend, link clicks, impressions, and actions.
  5. If Meta returns paging.next, configure pagination. A limit of 500 is not proof that every row arrived.
Expected shapeThe response has a data array with one record per ad per day.
06
PURCHASE CHECK

Confirm what “purchase” means

The first JavaScript node currently looks inside Meta’s actions array for an action type named purchase.

  1. Run the Meta request for an ad that definitely had purchases.
  2. Open its actions array and find the exact purchase action used by your account.
  3. If the name differs, update only that lookup in Code in JavaScript.
  4. Compare spend, purchases, and date with Ads Manager.
Do not skip thisIf the action name is wrong, every purchase becomes zero and the audit confidently gives bad advice.
07
IGNORE LIST

Start with no muted assets

Open Ignored_Assets_Config. The public workflow starts with an empty ignoredIds array.

  1. Leave it empty for the first comparison run.
  2. To mute something manually, add its ad ID or ad-set ID as text.
  3. Run the cleaner and confirm that ID disappears from dailyRecords.
No database neededThis small list lives on the workflow canvas. It is convenient for a short list, not a replacement for an audit log or large datastore.
08
EVALUATION ENGINE

Replace the example thresholds

Open Code in JavaScript1. Replace the target CPA, floor budget, skew percentage, daily spend floor, winner purchase count, and CTR-drop rule.

  1. Check the naming rule: the example treats ad sets containing “winner” or “scaling” as winner sets.
  2. Decide whether “Dead on Arrival” should stop other checks for that ad set.
  3. Review the five output arrays with known good and bad ads.
Good test fixtureUse one known winner, one fresh loser, one budget hog, one five-day miss, and one tired winner.
09
CONNECT SLACK

Choose where decisions arrive

Slack first appears after the evaluation, so connect it now.

  1. Create or reuse a Slack bot with permission to post messages.
  2. Connect the Slack credential in n8n and invite the bot to the ad-ops channel.
  3. Open Code in JavaScript2. Change the report title, currency symbol, and wording.
  4. Open Send a message and choose the destination channel.
10
FULL TEST

Compare before you trust it

ScheduleMeta dataFive rule bucketsSlack report
  1. Run the workflow manually while it is inactive.
  2. Compare at least three reported ads with Ads Manager using the same dates, timezone, attribution view, and currency.
  3. Check that every recommendation explains itself with spend, purchases, CPA, share, or CTR drop.
  4. Only then activate the daily audit.
The final decision stays humanThe workflow surfaces evidence. It does not understand launches, stock, promotions, creative strategy, or business context unless your team reviews it.
05Optional add-on
OPTIONAL · ADVANCED

Reply in Slack.
Mute future alerts.

Team members can reply STOP <ad_id> in the report thread. n8n adds that ID to its own ignore list and confirms the change.

SLACK THREADSTOP 120…585
SECURITY GATESigned by Slack ✓
N8N UPDATES ITSELFignoredIds + 1
THREAD REPLYMuted ✓
The supplied export does not include Slack signature verification.

For that reason, every add-on node is disabled in the public workflow. Do not enable this branch until card 02 is solved and tested. A public message-shaped request must never be allowed to rewrite your workflow.

Add-on 1 of 6
A1
MAKE A BACKUP

Clone the working audit

This add-on rewrites the workflow that contains it. Export the tested daily audit and make an inactive copy before continuing.

  1. Give the copy a clear “ADD-ON TEST” name.
  2. Keep the production audit active and untouched.
  3. Build and test the full STOP loop on the copy first.
Rollback planIf the canvas changes unexpectedly, stop and restore the manual export. Do not improvise on the live workflow.
A2
SECURITY GATE

Verify requests from Slack

Add a request-verification step before any message parsing or n8n API node.

  1. Use Slack’s signing secret from App Credentials.
  2. Verify X-Slack-Signature against the timestamp and raw request body.
  3. Reject stale timestamps, mismatches, wrong workspaces, and wrong channels.
  4. Keep the secret only in an n8n credential or protected environment variable.
Required before enablingA copied curl request without a valid Slack signature must fail before it reaches Code in JavaScript3.
A3
CONNECT N8N API

Let the copy read itself

Create an expiring n8n API key with the smallest workflow read/update access your plan supports.

  1. Create an n8n API credential using your instance’s /api/v1 base URL.
  2. Select that credential in Get a workflow and Update a workflow.
  3. Replace every workflow ID placeholder with the inactive copy’s ID.
  4. Test Get a workflow only. Confirm it returns the copy—not production.
A4
SLACK EVENT URL

Complete the challenge

Give the Webhook a long random path, publish the test copy, and paste its production URL into Slack Event Subscriptions.

  1. The first If node recognizes url_verification.
  2. Respond to Webhook returns Slack’s challenge as plain text.
  3. Real events go to Respond to Webhook1, which returns ACK immediately.
  4. Slack must receive a successful response within three seconds or it retries.
Green checkSlack marks the Request URL verified and one real event produces one n8n execution.
A5
MESSAGE FILTER

Listen only where needed

Subscribe to the channel-message event that matches your report channel and grant only its required history scope.

  1. Invite the bot to the report channel and reinstall after changing scopes.
  2. Filter for the correct workspace, channel, thread replies, and human users.
  3. Ignore bot messages and Slack retries.
  4. Keep the command strict: STOP 123… or STOP `123…`.
Harmless test firstInvalid text, another channel, the bot’s own reply, and an unsigned request must all stop before the update node.
A6
SELF-UPDATE TEST

Mute one disposable ID

  1. Enable the add-on nodes only on the inactive test copy.
  2. Reply with one test ad ID in the report thread.
  3. Confirm the ID is appended once to Ignored_Assets_Config.
  4. Confirm the Slack reply stays in the same thread.
  5. Run the daily branch and verify that ID is absent.
  6. Reopen the workflow and inspect every connection before moving the setup to production.
Know the trade-offThis avoids a database, but it also gives an inbound command permission to rewrite workflow JSON. Use it only if that convenience is worth the extra security and rollback work.
06Build with AI

Give the careful setup
to your coding agent.

It can customize, validate, and import the workflow. You still connect credentials, compare Meta results, and decide whether the risky add-on is worth enabling.

1
Open a fresh folder

Start a new Codex task inside it.

2
Paste the build brief

Codex prepares and validates the audit.

3
Approve the safe import

You keep credentials and activation manual.

CODEX CAN HANDLE

Workflow fetching · threshold changes · fixtures · importer code · secret scan · test plan

YOU STILL HANDLE

Tokens · OAuth · Meta comparison · Slack signing secret · activation · final decisions

BUILD BRIEF FOR CODEX
Build the “Meta Ad Brain” automation for me.

SOURCE OF TRUTH
- Guide: {{SITE_ORIGIN}}/automations/meta-ad-brain
- Sanitized workflow: {{SITE_ORIGIN}}/downloads/workflows/meta-ad-brain.json

HOW TO WORK
1. Read the guide and workflow before changing anything. Inspect both trigger branches and list every placeholder.
2. Create a short AGENTS.md with the plan, validation steps, and the rule that secrets, tokens, signing secrets, account data, and live webhook URLs must never enter source files or chat.
3. Ask me for these non-secret decisions: target CPA, minimum test budget, currency, spend-skew percentage, daily run time, n8n timezone, Meta ad account ID, winner/scaling naming clues, Slack report channel, and whether I want the optional STOP-command add-on.
4. Create .env.example with only N8N_BASE_URL and N8N_API_KEY. Tell me to put real values in .env myself. Never print or commit them.
5. Fetch the hosted workflow. Configure the daily branch first: current supported Graph API version, ad account placeholder, thresholds, naming clues, schedule, currency text, and Slack channel. Keep it inactive.
6. Create a small TypeScript importer that can send the workflow to my n8n instance after I approve the network write. Never create Meta, Slack, or n8n credentials automatically.
7. Validate the Meta response shape, purchase action type, pagination behavior, five output buckets, and Slack formatting with fixture data before import.
8. Keep every optional Slack-event/self-update node disabled unless I explicitly opt in. If I opt in, do not enable that branch until Slack signature verification, bot-event filtering, fast ACK behavior, a backup workflow export, and least-privilege n8n API access are all verified.
9. Ask for confirmation immediately before calling my n8n instance. Import one inactive workflow, then walk me through connecting credentials and testing three known ads against Ads Manager.

DONE MEANS
- The inactive daily audit imports successfully.
- The seven-day Meta request returns the expected fields and all pages.
- My thresholds and naming clues replace the examples.
- Five rule buckets produce understandable test results.
- One test report reaches the chosen Slack channel.
- The optional add-on is either safely completed and tested or remains disabled.

Start by summarizing the two branches, then ask me for the non-secret decisions.
Codex getting started ↗
07Need help?
Prateek Mallapur
ASK A HUMAN

Stuck somewhere?

Tell me which card you are on, what you expected, and what happened instead. For rule problems, include one anonymized Meta row and the bucket you expected.

Message hi@prateekm.com