Automate Amazon Ads Optimization with n8n and GPT-4o AI

Save hours manually analyzing Amazon Ads reports by automating data extraction from Google Drive, processing with GPT-4o AI, and emailing optimization insights. This workflow streamlines bid and budget recommendations tailored to your campaigns.
googleDrive
chainLlm
gmail
+8
Workflow Identifier: 1650
NODES in Use: googleDrive, if, set, extractFromFile, merge, code, chainLlm, lmChatOpenAi, gmail, manualTrigger, stickyNote

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Brian, an Amazon advertising manager overwhelmed by daily performance reports from multiple campaigns. Every morning, Brian downloads CSV and Excel reports, manually combs through search term data, campaign budgets, and targeting metrics. This labor-intensive process easily takes 3-4 hours daily and is prone to occasional errors in analysis, leading to missed optimization opportunities and wasted ad spend. Brian needs a better way to harness his data quickly and consistently, ensuring immediate, actionable recommendations for optimizing his Amazon Ads campaigns.

This is exactly where the “Amazon Ads AI Optimization” workflow in n8n shines.

2. What This Automation Does

When this workflow runs, it automates the entire cycle from report collection to actionable insights, specifically for Amazon Sponsored Products campaigns. Here’s what it does:

  • 1. Automatically scans a chosen Google Drive folder for freshly uploaded Amazon Ads reports in XLSX or CSV format.
  • 2. Downloads each report file and extracts structured data relevant to campaigns, search terms, targeting, placements, and budgets.
  • 3. Parses filenames to categorize reports into datasets such as search_terms, campaigns, targeting, placement, and budgets.
  • 4. Merges and cleans these parsed datasets into a unified JSON structure tailored for AI consumption.
  • 5. Sends the cleaned data as input to GPT-4o via n8n’s Langchain OpenAI node, which analyzes the data and generates specific campaign optimization recommendations—bid adjustments, budget scaling, and keyword and targeting suggestions.
  • 6. Formats the AI’s JSON response into a human-readable, detailed HTML email summary.
  • 7. Sends this personalized Amazon Ads optimization email automatically to the marketing team or campaign manager.

By automating this workflow, users save several hours daily, reduce manual error risk, and gain consistent, data-driven insights faster—empowering smarter bids and budget decisions that impact ad ROI positively.

3. Prerequisites ⚙️

  • n8n account configured and ready to run workflows
  • Google Drive account with OAuth2 access configured in n8n to read files
  • OpenAI API account with access to GPT-4o model configured via Langchain node in n8n
  • Gmail account authorized in n8n to send optimization summary emails
  • Amazon Ads accounts configured to schedule and deliver Sponsored Product reports (Search Term, Campaign, Targeting, Placement, Budget) daily to Google Drive or email

Optionally, self-host your n8n on platforms like Hostinger for full control and reliability: https://buldrr.com/hostinger

4. Step-by-Step Guide to Setup Amazon Ads AI Optimization in n8n

Step 1: Prepare Your Amazon Ads Reports

In your Amazon Ads Console, schedule the following reports to run every day for the last 30 days, in XLSX or CSV format:

  • Search Term Report (Detailed) → Sponsored_Products_Search_Term_Detailed_L30
  • Targeting Report (Detailed) → Sponsored_Products_Targeting_Detailed_L30
  • Campaign Report (Summary) → Sponsored_Products_Campaign_L30
  • Placement Report (Summary) → Sponsored_Products_Placement_L30
  • Budget Report (Summary) → Sponsored_Products_Budget_L30

Ensure filenames include these key words, so the workflow can identify them properly.

Step 2: Upload Reports to Google Drive Folder

Choose a dedicated Google Drive folder to hold all these report files. You can upload manually, set up Gmail automation to save attachments, or sync a local folder to Drive.

Note: The workflow’s List Files node must be configured to watch this folder for new files.

Step 3: Configure Google Drive Credentials in n8n

In n8n, add Google Drive OAuth2 credentials with read access to your reports folder.

Step 4: Set Email Details

Use the Email Options node to enter your recipient email address and email subject line.

You will later see this email setup used in the Gmail node.

Step 5: Set Up the Trigger

Initially, the workflow uses a manualTrigger node for testing. You can replace it with a scheduled trigger (e.g., Cron node) to run daily automatically.

Step 6: Configure the File Listing and Download

The List Files node scans the Drive folder and feeds all files one by one into the Get File node downloading each file as binary data.

Step 7: Identify File Types with “is XLSX” Node

The workflow uses an If node named is XLSX to check whether filenames contain .xlsx, to route files to the proper extractor.

Step 8: Extract Data from XLSX and CSV Files

Files detected as XLSX go to the Extract XLSX Data node; CSV files go to the Extract CSV Data node. Both parse the files into JSON for further processing.

Step 9: Preserve File Names

Each extracted file’s JSON data is tagged with filenames using Set nodes (Preserve File Name and Preserve CSV File Name) for routing downstream.

Step 10: Merge Data Streams

The Merge XLSX and CSV node consolidates data from both formats into one output stream for unified handling.

Step 11: Format Data Into Campaign Objects

A Code node named Format Data processes all incoming JSON objects. It maps filenames to categories like search_terms, campaigns, targeting, placement, and budgets. The code snippet carefully normalizes the name and throws errors if filename patterns don’t match. This step prepares neat structured input for AI analysis.

const result = {};

for (const item of items) {
  const fileName = item.json.fileName || item.json.name || 'unknown_file';
  const baseName = fileName
    .split('.')[0]
    .replace(/s+/g, '_')
    .toLowerCase()
    .replace(/s*(d+)$/, '')
    .replace(/_+$/, '')
    .trim();

  const map = [
    { key: 'search_terms', regex: /search_term/ },
    { key: 'campaigns',    regex: /campaign/     },
    { key: 'targeting',    regex: /targeting/   },
    { key: 'placement',    regex: /placement/   },
    { key: 'budgets',      regex: /budget/      },
  ];

  const entry = map.find(m => m.regex.test(baseName));
  const mappedKey = entry ? entry.key : null;

  if (!mappedKey) {
    throw new Error(`${fileName} → ${baseName} → Unrecognized file name structure`);
  }
  result[mappedKey] = result[mappedKey] || [];
  result[mappedKey].push(item.json);
}

return [{ json: result }];

Step 12: AI Analysis with GPT-4o

The prepared JSON object is sent to the AI Analyze node (Langchain’s chainLlm node) which uses GPT-4o with a specific system prompt. This prompt instructs the AI to analyze campaign data and return actionable recommendations like:

  • Campaign bid multipliers and bid placement adjustments
  • Budget increase/decrease actions for campaigns
  • Exact match keyword additions and negative keyword lists
  • Targeting recommendations (pause or increase bid on targets)

The AI returns a strict JSON format with these insights.

Step 13: Email Generated Optimizations

The workflow crafts a detailed HTML email summarizing all recommended campaign adjustments, keyword recommendations, and targeting tips in a user-friendly format. The Email Optimizations Gmail node sends this directly to the configured recipient.

5. Customizations ✏️

  • Change Report Folder: In the List Files Google Drive node, update the folderId filter to point to the Drive folder where your Amazon Ads reports are stored. This allows you to organize your reports in any folder without altering the workflow.
  • Email Recipients and Subject: Modify the Email Options node to customize who gets the optimization summary emails and subject lines, for better team collaboration or client reporting.
  • Switch AI Model: In the OpenAI Chat Model node, change the model from “gpt-4o” to any available OpenAI model according to your subscription or preference (e.g., gpt-4, gpt-3.5-turbo).
  • Upgrade to Amazon Ads API: Replace the manual report gathering with an automated connection to Amazon Advertising’s API to programmatically generate and fetch reports directly, eliminating manual uploads.
  • Customize AI Prompt: Refine the system prompt in the AI Analyze node to tailor recommendations to your business goals, like targeting specific ROAS thresholds or prioritizing certain campaign types.

6. Troubleshooting 🔧

Problem: Workflow fails to process files with error “Unrecognized file name structure”.
Cause: The uploaded report files do not match expected filename patterns.
Solution: Ensure filenames contain keywords like search_term, campaign, targeting, placement, or budget exactly as spelled. Rename files or adjust mapping regex in the Format Data node.

Problem: Emails are not sending.
Cause: Gmail OAuth2 credentials not authorized or setup incomplete.
Solution: Check and reauthorize Gmail OAuth2 credentials in n8n. Ensure the sending address matches authorized Gmail account. Test sending individual emails from the Gmail node.

Problem: AI response parsing fails in email template.
Cause: The AI model returned invalid JSON or unexpected format.
Solution: Examine the prompt in the AI Analyze node and confirm the AI outputs the strict required JSON. Test the AI node separately and validate JSON output before sending emails.

7. Pre-Production Checklist ✅

  • Verify Google Drive folder contains the correctly named files before workflow runs.
  • Test AI node separately with sample JSON input to validate response format.
  • Send test emails using the Gmail node with your address to check formatting and delivery.
  • Backup your n8n workflow and credential configurations before production deployment.

8. Deployment Guide

Activate your workflow by enabling it in n8n. Replace the manual trigger node with a Cron trigger or other schedule trigger node to run daily after reports are expected to be uploaded.

Monitor workflow executions in n8n logs. Set up error alerts via email or webhook for failures in file extraction or AI processing nodes.

9. FAQs

Q: Can I use email attachments directly instead of Google Drive?
A:
Yes, but you need to add a Gmail trigger node and automatic uploader to Google Drive or adapt the workflow to parse attachments directly.

Q: Does this consume a lot of OpenAI API credits?
A:
The AI model GPT-4o is a powerful model and may use moderate credits depending on data size; limit frequency accordingly.

Q: Is my data secure?
A:
Data flows through your n8n environment and cloud services; ensure you comply with your organization’s privacy policies and secure credentials properly.

10. Conclusion

By following this comprehensive guide, you’ve built an end-to-end automated Amazon Ads optimization workflow using n8n and GPT-4o. This workflow frees you from time-consuming manual report analysis by automatically ingesting campaign data from Google Drive, classifying and formatting it, then leveraging powerful AI to generate specific bid, budget, and keyword recommendations—all delivered cleanly via email.

You save hours each week, reduce costly errors from manual processing, and gain precision in campaign adjustments. Next, consider automating Amazon Ads campaign creation or integrating with Google Sheets dashboards for real-time tracking.

Start improving your Amazon Ads performance with fewer headaches and more data-driven confidence.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free