This workflow corresponds to n8n.io template #10441 — we link there as the canonical source.
This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "69fCeA2DKyEPBdgz",
"name": "Client Reporting Automation Agent",
"tags": [],
"nodes": [
{
"id": "090a0d29-5926-4266-b42b-cc5d5fbb502a",
"name": "Format Data",
"type": "n8n-nodes-base.code",
"position": [
-784,
784
],
"parameters": {
"jsCode": "return items.map(item => {\n const data = item.json;\n\n const flattened = {\n campaign_name: data.campaign_name,\n impressions: Number(data.impressions),\n clicks: Number(data.clicks),\n spend: Number(data.spend),\n date_start: data.date_start,\n date_stop: data.date_stop\n };\n\n // Flatten all action types\n if (Array.isArray(data.actions)) {\n data.actions.forEach(action => {\n flattened[action.action_type] = Number(action.value);\n });\n }\n\n return { json: flattened };\n});\n"
},
"typeVersion": 2
},
{
"id": "366ea06c-4986-4c0d-9d6a-ffa85a346ff0",
"name": "Fetch FB Data",
"type": "n8n-nodes-base.httpRequest",
"position": [
-976,
784
],
"parameters": {
"url": "https://graph.facebook.com/v20.0/act_{{Your_Ad_Account_ID}}/insights?fields=campaign_name,impressions,clicks,spend,actions&date_preset=last_7d&access_token=YOUR_TOKEN_HERE",
"options": {},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Auth",
"value": "={{FACEBOOK_ACCESS_TOKEN}}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "d0fb8976-c2ab-435b-bb8c-73d495e443be",
"name": "Weekly Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-1152,
784
],
"parameters": {
"rule": {
"interval": [
{
"field": "weeks",
"triggerAtDay": [
1
],
"triggerAtHour": 8,
"triggerAtMinute": 30
}
]
}
},
"typeVersion": 1.2
},
{
"id": "348d4484-5ccd-40f1-8cff-1f7e623c7ee6",
"name": "Merge Reports",
"type": "n8n-nodes-base.aggregate",
"position": [
-960,
1024
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "output"
}
]
}
},
"typeVersion": 1
},
{
"id": "6d7c6e2f-2400-4e4e-b7ef-dce6aba9df45",
"name": "Generate PDF",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1152,
1264
],
"parameters": {
"url": "https://api.pdfcrowd.com/convert/24.04",
"method": "POST",
"options": {
"response": {
"response": {
"responseFormat": "file",
"outputPropertyName": "Facebook_Ads_Report_Week_of_Aug_12_2025.pdf"
}
}
},
"sendBody": true,
"contentType": "form-urlencoded",
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{
"name": "content_viewport_width",
"value": "balanced"
},
{
"name": "text",
"value": "={{ $json.html }}"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "authorization",
"value": "Basic {{PDFCROWD_API_KEY}}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "0a9ff2f7-075a-415a-a1f5-5e3b579ea057",
"name": "Send Email",
"type": "n8n-nodes-base.gmail",
"position": [
-944,
1264
],
"parameters": {
"message": "\ud83d\udce9 \ud835\uddea\ud835\uddf2\ud835\uddf2\ud835\uddf8\ud835\uddf9\ud835\ude06 \ud835\uddd9\ud835\uddee\ud835\uddf0\ud835\uddf2\ud835\uddef\ud835\uddfc\ud835\uddfc\ud835\uddf8 \ud835\uddd4\ud835\uddf1\ud835\ude00 \ud835\udde3\ud835\uddf2\ud835\uddff\ud835\uddf3\ud835\uddfc\ud835\uddff\ud835\uddfa\ud835\uddee\ud835\uddfb\ud835\uddf0\ud835\uddf2 \ud835\udde5\ud835\uddf2\ud835\uddfd\ud835\uddfc\ud835\uddff\ud835\ude01\n\nI hope you had a refreshing weekend! \ud83c\udf1e\n\n\ud83d\udcca \ud835\udde4\ud835\ude02\ud835\uddf6\ud835\uddf0\ud835\uddf8 \ud835\udddb\ud835\uddf6\ud835\uddf4\ud835\uddf5\ud835\uddf9\ud835\uddf6\ud835\uddf4\ud835\uddf5\ud835\ude01\ud835\ude00:\n\u2705 \ud835\udde7\ud835\uddfc\ud835\uddfd \ud835\uddf0\ud835\uddee\ud835\uddfa\ud835\uddfd\ud835\uddee\ud835\uddf6\ud835\uddf4\ud835\uddfb: New Product Launch\n\u26a0\ufe0f \ud835\udde8\ud835\uddfb\ud835\uddf1\ud835\uddf2\ud835\uddff\ud835\uddfd\ud835\uddf2\ud835\uddff\ud835\uddf3\ud835\uddfc\ud835\uddff\ud835\uddfa\ud835\uddf6\ud835\uddfb\ud835\uddf4 \ud835\uddf0\ud835\uddee\ud835\uddfa\ud835\uddfd\ud835\uddee\ud835\uddf6\ud835\uddf4\ud835\uddfb: Retargeting Campaign\n\ud83d\udca1 \ud835\uddde\ud835\uddf2\ud835\ude06 \ud835\uddff\ud835\uddf2\ud835\uddf0\ud835\uddfc\ud835\uddfa\ud835\uddfa\ud835\uddf2\ud835\uddfb\ud835\uddf1\ud835\uddee\ud835\ude01\ud835\uddf6\ud835\uddfc\ud835\uddfb: Optimize landing pages with better user experience and persuasive elements to boost conversions from clicks to purchases.\n\nThe \ud835\uddf1\ud835\uddf2\ud835\ude01\ud835\uddee\ud835\uddf6\ud835\uddf9\ud835\uddf2\ud835\uddf1 \ud835\udde3\ud835\uddd7\ud835\uddd9 \ud835\uddff\ud835\uddf2\ud835\uddfd\ud835\uddfc\ud835\uddff\ud835\ude01 \ud835\uddf6\ud835\ude00 \ud835\uddee\ud835\ude01\ud835\ude01\ud835\uddee\ud835\uddf0\ud835\uddf5\ud835\uddf2\ud835\uddf1 \ud835\uddf3\ud835\uddfc\ud835\uddff \ud835\uddff\ud835\uddf2\ud835\ude03\ud835\uddf6\ud835\uddf2\ud835\ude04. Wishing you a productive and successful week ahead! \ud83d\ude80\n\nBest regards,\nMuhammad Ali Zubair\nAI Automation Expert",
"options": {
"attachmentsUi": {
"attachmentsBinary": [
{
"property": "Facebook_Ads_Report_Week_of_Aug_12_2025.pdf"
}
]
},
"appendAttribution": false
},
"subject": "Weekly Facebook Ads Report | Aug 12 \u2013 Aug 18, 2025",
"emailType": "text"
},
"typeVersion": 2.1
},
{
"id": "1ea42b59-b07d-427f-8592-d62b4bfbc7bb",
"name": "AI Report Writer",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-752,
1024
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"content": "=Summary of All Compaigns: {{ $json.output }} "
},
{
"role": "system",
"content": "=You are a senior performance marketing analyst. Analyze multiple Facebook Ads campaign summaries and produce one concise, insight-rich HTML report.\n\nInput: JSON array of campaigns. Each item may include: campaign_name, date_start, date_stop, impressions, clicks, spend, action metrics (link_click, purchase), and a short per-campaign summary from another agent.\n\nOutput rules:\n\nOutput valid HTML5 only. No Markdown. No code fences. No scripts. No styles.\n\nUse this heading structure:\n\n<h1> Weekly Facebook Ads Performance Report\n\n<h2> Campaign Analysis\n\nFor each campaign: <h3> [Campaign Name]\n\nFor each campaign block:\n\nShow a <p> line for Date Range.\n\nAdd an Insights list as <ul><li>...</li></ul>. Use simple words. Show rates with a % sign when possible. If a metric is missing, write unavailable.\n\nAdd a Recommendations list as <ul><li>...</li></ul> with 3 to 5 specific next steps about audience, creative, budget, bidding, placements, or experiments.\n\nAfter listing all campaigns, add:\n\n<h2> Summary and Recommendations\n\nThree sections in plain English using <p> and <ul>:\n\nWhich campaigns performed best and why\n\nWhich campaigns underperformed and why\n\nRecommendations to improve results next week\n\nBe objective. Do not invent data. If you infer, say that you inferred it.\n\nKeep language simple and client friendly. Use short sentences. Avoid difficult terms. Avoid hyphens and long dashes.\n\nFormatting requirements:\n\nStart the response with <!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>Weekly Facebook Ads Performance Report</title></head><body> and end with </body></html>.\n\nUse only <h1>, <h2>, <h3>, <p>, <ul>, <li>, <strong>, <em>, and <table>/<tr>/<th>/<td> if needed for compact numbers.\n\nKeep paragraphs short. Prefer bullet points for clarity.\n\nAlways include the % sign for rates when shown."
}
]
}
},
"typeVersion": 1.8
},
{
"id": "e942ddc4-7ed3-4bd5-90a6-ca8c4eb96dc3",
"name": "Set Node",
"type": "n8n-nodes-base.set",
"position": [
-448,
1024
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "f3f3f52d-210f-4646-b011-d3be9af6c1f5",
"name": "html",
"type": "string",
"value": "={{ $json[\"message\"][\"content\"] }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "d9f04e45-24c3-4f5a-ac01-6d007d571558",
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1168,
1040
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "5776dd7f-4d53-42f7-87c7-f5ec254099bd",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1200,
704
],
"parameters": {
"color": 4,
"width": 576,
"height": 224,
"content": "## Fetch & Format Data"
},
"typeVersion": 1
},
{
"id": "485d88f1-b0e8-4087-ad2e-d3e4d46cff5b",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1200,
976
],
"parameters": {
"color": 3,
"width": 160,
"height": 192,
"content": "### Chat Model"
},
"typeVersion": 1
},
{
"id": "c6e90a0b-f30f-4d3d-a70f-b7d491e42cb9",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1008,
976
],
"parameters": {
"color": 3,
"width": 704,
"height": 192,
"content": "## Generate Final Performance Report"
},
"typeVersion": 1
},
{
"id": "806c115a-94de-4b9d-8887-8e99c5501812",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-608,
704
],
"parameters": {
"color": 5,
"width": 304,
"height": 224,
"content": "## Summarize Compaign Performance"
},
"typeVersion": 1
},
{
"id": "acb9c4a7-f07f-4a91-863d-53a09c4e70cd",
"name": "AI Summarizer",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-576,
784
],
"parameters": {
"text": "=Here is Detail TO analyze\nCampaign_name: {{ $json.campaign_name }}\nImpressions: {{ $json.impressions }}\nclicks: {{ $json.clicks }}\nspend: {{ $json.spend }}\ndate_start :{{ $json.date_start }}\ndate_END {{ $json.date_stop }}\nPurchase:{{ $json.purchase }}\nlink_click: {{ $json.link_click }}",
"options": {
"systemMessage": "You are a marketing analyst specializing in Facebook Ads reporting. \nYour task is to analyze a single campaign's performance and generate a clear, actionable summary. \n\nYou will receive the following campaign data for the week: \n- Campaign Name \n- Date Range (date_start \u2013 date_stop) \n- Impressions \n- Clicks (all ad interactions) \n- Spend \n- Actions (e.g., link_click, purchase, etc.) \n\nYour output must include: \n\n1. Campaign Name \n2. Date Range \n3. Insights \n - Engagement: impressions, CTR, cost per click, engagement trends. \n - Traffic: link clicks, landing page visits, efficiency of driving traffic. \n - Conversions: purchases or other key actions, cost per purchase, ROAS if possible. \n - Highlight strengths and weaknesses clearly. \n\n4. Recommendations \n - Provide 3\u20135 **specific, actionable next steps** to improve this campaign\u2019s performance next week (e.g., optimize targeting, adjust creative, retargeting, budget allocation, testing strategies). \n\nRules: \n- Focus only on this campaign. Do not compare it to other campaigns. \n- Keep the tone concise, professional, and client-friendly (plain English, no heavy jargon). \n- If some metrics are missing, state they are unavailable and infer cautiously. \n- Output in clear sections with headings and short paragraphs or bullet points. \n"
},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"id": "a362c4cb-ed71-4449-b099-e9a72e99a064",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1200,
1200
],
"parameters": {
"width": 464,
"height": 224,
"content": "## Generate & Share PDF"
},
"typeVersion": 1
},
{
"id": "60efabe6-53fc-421f-a33d-6dfbb952eaaf",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1728,
704
],
"parameters": {
"width": 432,
"height": 752,
"content": "## Facebook Ads Weekly Performance Report Generator\n\nThis workflow automatically generates a professional weekly report of your Facebook ad campaigns and sends it to your client via email.\n\n### \ud83e\udde9 What It Does\nEvery Monday, it:\n1. Fetches the last 7 days of campaign data from Facebook Ads.\n2. Formats and summarizes each campaign\u2019s performance using AI.\n3. Merges all summaries into a final detailed performance report.\n4. Generates a branded PDF report.\n5. Sends it to the client automatically via Gmail.\n\n### \ud83d\udca1 Why Use It\nNo more manual data pulling or writing reports! \nThis template helps marketing teams save hours by automating analytics, insights, and PDF reporting.\n\n### \u2699\ufe0f Requirements\n- Facebook Graph API Access Token \n- OpenAI API Key (for report writing and summarization) \n- PDFCrowd API Key (for PDF generation) \n- Gmail credentials in n8n \n\n### \ud83e\udde0 Tip\nYou can easily customize the time period, email content, or design of the PDF."
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "7b2985a5-534f-4bb6-af3b-b217bac641db",
"connections": {
"OpenAI": {
"ai_languageModel": [
[
{
"node": "AI Summarizer",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Set Node": {
"main": [
[
{
"node": "Generate PDF",
"type": "main",
"index": 0
}
]
]
},
"Format Data": {
"main": [
[
{
"node": "AI Summarizer",
"type": "main",
"index": 0
}
]
]
},
"Generate PDF": {
"main": [
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
]
]
},
"AI Summarizer": {
"main": [
[
{
"node": "Merge Reports",
"type": "main",
"index": 0
}
]
]
},
"Fetch FB Data": {
"main": [
[
{
"node": "Format Data",
"type": "main",
"index": 0
}
]
]
},
"Merge Reports": {
"main": [
[
{
"node": "AI Report Writer",
"type": "main",
"index": 0
}
]
]
},
"Weekly Trigger": {
"main": [
[
{
"node": "Fetch FB Data",
"type": "main",
"index": 0
}
]
]
},
"AI Report Writer": {
"main": [
[
{
"node": "Set Node",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Perfect for marketing agencies that manage multiple Facebook ad accounts and want to automate their weekly reporting. It eliminates manual data collection, analysis, and client updates by delivering a ready-to-share PDF report.
Source: https://n8n.io/workflows/10441/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow automates the creation, rendering, approval, and posting of TikTok-style POV (Point of View) videos to Instagram, with cross-posting to Facebook and YouTube. It eliminates manual video p
This workflow automates the process of generating, reviewing, and publishing blog posts across multiple platforms, now enhanced with support for RSS Feeds as a content source. It streamlines the manag
This n8n workflow automatically generates AI-powered content about local news and publishes it across multiple social media platforms. The workflow runs on a schedule, fetches the latest news about a
Automatically compare AI-generated email drafts against what your support team actually sent, learn from the differences, and improve future drafts over time — without any model fine-tuning.
An end-to-end automation system that monitors TikTok accounts for new 3-image carousel posts, extracts text overlays and visual layouts using AI vision analysis, translates content into English, and a