Quick overview
This workflow runs weekly to pull Meta Ads campaign and ad-level insights from the Meta Graph API, summarizes performance, generates charts with QuickChart, asks Google Gemini for written analysis, converts the resulting HTML report to a PDF via PDFShift, and emails it through Gmail.
How it works
- Runs every Monday at 8:00 AM using a schedule trigger.
- Builds the reporting date range (last 7/14/30 days based on your schedule setting) and loads the Meta Ads account ID, access token, company name, and report recipient email.
- Calls the Meta Graph API to fetch ad account details plus daily campaign-level insights for the selected period.
- Aggregates campaign metrics (spend, impressions, clicks, CTR, CPC, CPM, results, revenue/ROAS) and prepares daily totals used for reporting.
- Pulls the top ads by spend from the Meta Graph API and fetches each ad’s creative details (thumbnail, body, title) to enrich the ad performance data.
- Generates chart image URLs with QuickChart, sends a structured performance summary to Google Gemini for narrative insights and next steps, and builds a branded HTML report.
- Converts the HTML to a PDF using PDFShift and emails the PDF report to the configured recipient via Gmail.
Setup
- Create or obtain a Meta access token with
ads_read permissions and set your Meta Ads Account ID (without the act_ prefix) and token in the workflow’s configuration values.
- Add Google Gemini (PaLM) API credentials for the model call.
- Add PDFShift HTTP Basic Auth credentials (API key) for the PDF conversion request.
- Connect a Gmail OAuth2 account and set the recipient email address that should receive the weekly PDF report.
- (Optional) Update the schedule trigger timing and the reporting schedule setting (Weekly, Biweekly, Monthly) to control when and how far back the report pulls data.