X and Facebook to Gmail, clear sentiment summaries
Your brand is getting talked about on X and Facebook. The annoying part is turning that noise into something you can actually use without spending your morning screenshotting comments, guessing tone, and pasting snippets into a “quick report” nobody trusts.
Social media managers feel it first. Then the marketing lead asking “what’s the vibe this week?” And the consultant who needs a tidy update for a client call. This sentiment report automation pulls the mentions and comments together and turns them into one clean Gmail summary you can forward in seconds.
You’ll see how the workflow collects data from both platforms, runs GPT-4o sentiment and keyword analysis, and emails a polished HTML report (with error logging so you’re not flying blind).
How This Automation Works
Here’s the complete workflow you’ll be setting up:
n8n Workflow Template: X and Facebook to Gmail, clear sentiment summaries
flowchart LR
subgraph sg0["When clicking ‘Execute workflow’ Flow"]
direction LR
n0@{ icon: "mdi:play-circle", form: "rounded", label: "When clicking ‘Execute workf..", pos: "b", h: 48 }
n1@{ icon: "mdi:brain", form: "rounded", label: "Configure GPT-4o Model", pos: "b", h: 48 }
n2@{ icon: "mdi:brain", form: "rounded", label: "Configure GPT-4o Model1", pos: "b", h: 48 }
n3["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Fetch Recent Mentions (X API)"]
n4["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/facebook.svg' width='40' height='40' /></div><br/> Fetch Recent Facebook Comme.."]
n5["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/merge.svg' width='40' height='40' /></div><br/>Merge Platform Datasets"]
n6["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Consolidate Mentions & Comme.."]
n7@{ icon: "mdi:robot", form: "rounded", label: "Perform Sentiment & Keyword ..", pos: "b", h: 48 }
n8["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/> Parse AI Output to Structur.."]
n9@{ icon: "mdi:robot", form: "rounded", label: " Generate Audience Sentiment..", pos: "b", h: 48 }
n10@{ icon: "mdi:message-outline", form: "rounded", label: "Send Email Summary to Market..", pos: "b", h: 48 }
n11@{ icon: "mdi:database", form: "rounded", label: "Log Errors in Google Sheets", pos: "b", h: 48 }
n12@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Validate API Response Integr..", pos: "b", h: 48 }
n1 -.-> n7
n2 -.-> n9
n5 --> n12
n3 --> n5
n12 --> n6
n12 --> n11
n4 --> n5
n6 --> n7
n8 --> n9
n9 --> n10
n0 --> n4
n0 --> n3
n7 --> n8
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0 trigger
class n7,n9 ai
class n1,n2 aiModel
class n12 decision
class n11 database
class n3,n4 api
class n6,n8 code
classDef customIcon fill:none,stroke:none
class n3,n4,n5,n6,n8 customIcon
Why This Matters: Turning scattered comments into a real signal
Keeping up with brand sentiment sounds simple until you try to do it consistently. X mentions live in one place, Facebook comments in another, and the context gets lost as soon as you start copy-pasting. One person flags a “negative” comment, another calls it “neutral sarcasm,” and suddenly the report is more opinion than insight. Meanwhile, you are burning time on the same cycle: collect, skim, summarize, format, send, repeat. The cost isn’t just hours. It’s delayed response when mood shifts, and missed themes that could have informed a campaign before it launched.
The friction compounds fast. Here’s where it usually breaks down.
- You jump between X and Facebook to gather feedback, and it turns into about an hour of tab juggling every time you do it.
- Sentiment gets inconsistent because humans interpret tone differently, especially when comments are short or sarcastic.
- By the time you format something shareable, it’s already outdated, so decisions get made on “last week’s vibe.”
- When an API call fails, you may not notice until someone asks why the report didn’t show up.
What You’ll Build: An AI sentiment digest delivered to Gmail
This workflow gives you a repeatable way to turn raw social chatter into a readable update your team will actually open. You start it manually (and you can schedule it later), and it immediately fetches the latest X mentions and Facebook post comments through their APIs. Those two datasets get merged, then normalized into a unified structure so “mention,” “comment,” and “reply” are treated consistently. Next, GPT-4o analyzes sentiment and pulls out keyword themes, returning structured JSON you can reuse for dashboards. A second AI step turns those findings into a polished HTML email summary, which then gets sent via Gmail to your chosen recipients. If anything fails along the way, the workflow logs the error to Google Sheets so you have an audit trail instead of mystery outages.
The flow is simple once it’s in place. Pull data from X and Facebook. Validate it, standardize it, then let GPT-4o classify mood and extract trends. Finally, Gmail delivers a ready-to-forward report while Google Sheets quietly captures errors in the background.
What You’re Building
| What Gets Automated | What You’ll Achieve |
|---|---|
|
|
Expected Results
Let’s say you create a sentiment update three times a week. Manually, you might spend about 30 minutes pulling X mentions, another 30 minutes grabbing Facebook comments, then about an hour to interpret tone, write themes, and format an email. Call it roughly 2 hours per report, so around 6 hours a week. With this workflow, the “work” becomes starting the run (or letting it run on a schedule) and skimming the Gmail summary for a quick sanity check, usually about 10 minutes.
Before You Start
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- X (Twitter) API access to fetch recent mentions.
- Facebook Graph API access to read page posts and comments.
- Azure OpenAI API key (get it from the Azure OpenAI resource in your Azure portal).
Skill level: Intermediate. You’ll connect OAuth/API credentials and paste a few IDs/tokens into the right nodes.
Want someone to build this for you? Talk to an automation expert (free 15-minute consultation).
Step by Step
You kick it off manually (at first). The workflow begins with a Manual Execution trigger, which is perfect for testing. Once you trust the output, you can switch to a scheduled trigger so it arrives daily or weekly.
Data gets pulled from X and Facebook. An HTTP Request node retrieves X mentions, and a Facebook Graph API node fetches comments and feedback. Those two streams get merged into one dataset so you’re not analyzing in silos.
Validation and cleanup happen before AI touches anything. An If/validation step checks that the API responses are complete, then a Code step “unifies” the items into a consistent structure. This is where missing fields and mismatched formats get handled so GPT-4o doesn’t produce messy output.
GPT-4o analyzes sentiment and themes, then writes the report. The AI Agent runs sentiment and keyword trend analysis and returns structured JSON. Another AI step turns that data into a human-readable HTML summary, and Gmail sends it to your list of recipients.
You can easily modify the reporting cadence to daily or weekly based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Manual Execution Trigger
Set up the manual trigger and confirm the workflow starts with parallel data collection.
- Add the Manual Execution Start node as the trigger for testing and manual runs.
- Confirm the execution flow where Manual Execution Start outputs to both Fetch Facebook Feedback and Retrieve X Mentions in parallel.
- Keep the trigger parameters empty, as shown in Manual Execution Start.
Step 2: Connect Social Data Sources
Configure the X and Facebook data pulls with the exact API parameters and credentials.
- In Retrieve X Mentions, set URL to
https://api.x.[CONFIGURE_YOUR_API_KEY]?tweet.fields=created_at,text,public_metrics,author_idand keep Authentication set topredefinedCredentialType. - Credential Required: Connect your twitterOAuth2Api credentials in Retrieve X Mentions.
- In Fetch Facebook Feedback, set Edge to
posts, Node to[YOUR_ID], and Graph API Version tov23.0. - Credential Required: Connect your facebookGraphApi credentials in Fetch Facebook Feedback.
- Verify both nodes feed into Combine Platform Data so the merge receives both data streams.
Step 3: Merge and Validate Incoming Data
Unify the platform responses, validate that data exists, and route errors to Google Sheets.
- Keep Combine Platform Data connected from both data sources to merge the X and Facebook responses.
- In Validate API Responses, configure the conditions using the exact expressions: Left Value
{{ $json.data.id }}with operatornotEmpty, and a second condition Left Value{{ 1 }}equals1. - Connect the true output from Validate API Responses to Unify Mentions Comments.
- Connect the false output from Validate API Responses to Record Errors to Sheets for logging.
- Credential Required: Connect your googleSheetsOAuth2Api credentials in Record Errors to Sheets.
data, the validation in Validate API Responses may route valid runs to the error log.Step 4: Normalize Data and Run Sentiment Analysis
Normalize all posts and comments, then send the unified dataset to the AI sentiment analyzer.
- In Unify Mentions Comments, keep the provided JavaScript for normalization and ensure the output includes unified_comments.
- In Run Sentiment Keyword Analysis, set Text to the provided prompt and keep the expression
{{ JSON.stringify($json.unified_comments) }}in place. - Open Azure GPT Setup A and set Model to
gpt-4o. - Credential Required: Connect your azureOpenAiApi credentials in Azure GPT Setup A. This is the language model used by Run Sentiment Keyword Analysis.
Step 5: Generate the Audience Report and Email It
Parse the AI output, create a polished HTML summary, and send the report to email.
- In Parse AI Output JSON, keep the parsing script to convert the model output into structured JSON.
- In Create Audience Summary, keep the HTML-focused prompt and formatting instructions for email-ready output.
- Open Azure GPT Setup B and set Model to
gpt-4o. - Credential Required: Connect your azureOpenAiApi credentials in Azure GPT Setup B. This is the language model used by Create Audience Summary.
- In Dispatch Email Report, set Send To to
[YOUR_EMAIL], Subject toAudience Sentiment and Keyword Trend Monitoring, and Message to{{ $json.output }}. - Credential Required: Connect your gmailOAuth2 credentials in Dispatch Email Report.
Step 6: Test and Activate Your Workflow
Run a manual test to verify the full data path and then activate the workflow for ongoing use.
- Click Execute Workflow from Manual Execution Start to run a full test.
- Confirm the parallel run where Manual Execution Start triggers both Fetch Facebook Feedback and Retrieve X Mentions.
- Verify Dispatch Email Report sends an email containing HTML output from Create Audience Summary.
- Check Record Errors to Sheets only runs when Validate API Responses fails.
- When satisfied, toggle the workflow to Active for production use.
Troubleshooting Tips
- Facebook Graph API credentials can expire or lack the right scopes. If things break, check your app permissions and token status in Meta for Developers first.
- If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.
Quick Answers
About 30 minutes if you already have the API credentials.
No. You will mainly connect accounts and paste a few IDs/tokens into the right nodes.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in Azure OpenAI usage, which is usually a few cents per run for summaries at modest volume.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and you probably should. You can change what you pull by editing the “Retrieve X Mentions” and “Fetch Facebook Feedback” nodes (different queries, different pages, different time windows). The “Create Audience Summary” AI step is where you tailor the format for leadership, clients, or product teams. Common tweaks include adding competitor keywords, splitting sentiment by product line, or sending separate emails per region.
Usually it’s expired OAuth permissions or a changed Google security setting. Reconnect the Gmail credential in n8n and confirm the account still allows third-party access. Also double-check the “GMAIL_REPORT_RECIPIENTS” value (or the recipient field in the Gmail node), because an invalid address can look like a send failure. If it works once and then stops, rate limits or account policy changes are often the culprit.
If you self-host, there’s no execution limit (it mainly depends on your server and API rate limits). On n8n Cloud, your monthly execution limit depends on the plan, and this workflow uses one execution per run. Practically, most teams run it daily or weekly and analyze dozens to a few hundred items per run. If you’re pulling thousands of comments at once, expect longer AI processing time and consider batching.
Often, yes. This workflow isn’t just “send data from A to B”; it merges datasets, validates responses, runs structured AI analysis, and formats a full HTML report, which is the kind of multi-step logic that gets awkward (and expensive) in simpler automation tools. n8n also gives you a self-host option, which can matter if you run frequent reports or want tighter control over data handling. Zapier or Make can still work if your needs are lightweight, like forwarding a single alert when a keyword appears. If you’re unsure, Talk to an automation expert and describe your reporting cadence and volumes.
Once this is running, your inbox becomes the single place to check “how people feel” without the manual scramble. The workflow handles the repetitive digging, and you get to act on the insight.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.