Send weekly Facebook and Instagram PDF performance reports with Gemini and Gmail

Go to Workflow
0 views
Built by SPCTEK AI SPCTEK AI
Created on June 09, 2026

Description

Quick Overview
This workflow runs every Monday morning, pulls last week’s Facebook Page and Instagram Business metrics from the Meta Graph API, generates chart images, asks Google Gemini to write a narrative analysis, converts a branded HTML report to PDF via PDFShift, and emails it using Gmail.

How it works
Runs on a weekly schedule (Mondays at 8:00) and sets the Facebook/Instagram IDs, access tokens, and report recipient email.
Calculates the last full week date range (Monday–Sunday) and uses it to query the Meta Graph API.
Fetches Facebook Page feed posts plus daily page views, post engagements, and organic media views, then aggregates totals and a structured post list.
Fetches Instagram media posts and daily insights (reach, profile views, accounts engaged, interactions, and follows/unfollows) plus an organic views breakdown, then summarizes the week.
Merges Facebook and Instagram results and generates chart image URLs using QuickChart for key daily metrics.
Sends the combined stats to Google Gemini to produce a five-section weekly analysis, then builds a branded HTML report including charts, post previews, and next steps.
Converts the HTML to a PDF with PDFShift and emails the PDF report to the configured recipient via Gmail.

Setup
Create Meta Graph API access tokens and update the workflow with your Facebook Page ID, Instagram Business Account ID, a long-lived Meta access token, and a Facebook Page access token.
Add your Google Gemini (PaLM) API credential and select an available model (the template uses gemini-3-flash-preview).
Add a PDFShift HTTP Basic Auth credential (API key) for https://api.pdfshift.io/v3/convert/pdf.
Connect a Gmail OAuth2 credential and confirm the recipient email address used for the report.
Review the schedule trigger time zone and timing so it runs at your intended Monday 08:00 slot.

Nodes Used (5)

Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
Google Gemini
@n8n/n8n-nodes-langchain.googleGemini
HTTP Request
n8n-nodes-base.httpRequest
OpenAI
@n8n/n8n-nodes-langchain.openAi