Skip to main content

Analyze social media sentiment & trends from Twitter & Facebook using GPT-4o

Workflow preview

Workflow preview
100%
Analyze social media sentiment & trends from Twitter & Facebook using GPT-4o preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Description Gain real time audience intelligence with this cross platform AI Sentiment Analyzer for Twitter (X) and Facebook. This workflow consolidates mentions and comments, performs GPT 4o ...

Best for

  • Market Research automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, @n8n/n8n-nodes-langchain.lmchatazureopenai, n8n-nodes-base.httprequest, n8n-nodes-base.facebookgraphapi, n8n-nodes-base.merge, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.gmail

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Rahul Joshi.

Original n8n.io source

1.1 Workflow description

Title
Analyze social media sentiment & trends from Twitter & Facebook using GPT-4o
Workflow name
Analyze social media sentiment & trends from Twitter & Facebook using GPT-4o

Description

Gain real-time audience intelligence with this cross-platform AI Sentiment Analyzer for Twitter (X) and Facebook. 📊🧠 This workflow consolidates mentions and comments, performs GPT-4o-powered sentiment and keyword analysis, summarizes audience mood, highlights dominant trends, and sends a polished HTML report via email — all automatically. Ideal for marketing and insights teams tracking brand conversations across social platforms. 🚀💬

What This Template Does

1️⃣ Starts manually to fetch the latest Twitter mentions and Facebook post comments. 🕹️ 2️⃣ Merges both datasets into a unified JSON structure for seamless cross-platform analysis. 🧩 3️⃣ Validates incoming API data to ensure completeness before processing. ✅ 4️⃣ Runs a custom JavaScript transformation to normalize all messages and add sentiment placeholders. 🧠 5️⃣ Uses GPT-4o to perform sentiment and keyword trend analysis, returning structured JSON insights. 📈 6️⃣ Parses AI output to extract overall sentiment ratios and detailed post-level analysis. 🔍 7️⃣ Generates a human-readable HTML summary using GPT-4o — featuring emojis, bullet insights, and trend sections. 🎨 8️⃣ Emails the formatted sentiment report directly to the marketing team. ✉️ 9️⃣ Logs API or runtime errors automatically into Google Sheets for transparent monitoring. 🧾

Key Benefits

✅ Provides an automated end-to-end pipeline for sentiment intelligence. ✅ Centralizes Twitter and Facebook audience data in one workflow. ✅ Delivers structured insights ready for dashboards or client reporting. ✅ Generates branded HTML summaries that are ready for emailing. ✅ Improves reliability with built-in error tracking and validation layers.

Features

  • Dual-platform integration (Twitter X API + Facebook Graph API).
  • JavaScript logic for merging and normalizing social datasets.
  • GPT-4o-based sentiment classification and keyword extraction.
  • Structured JSON parsing and visualization pipeline.
  • AI-generated HTML summary reports for presentation and sharing.
  • Automated email dispatch via Gmail.
  • Google Sheets logging for audit and debugging.
  • Modular configuration — easily extendable to other social networks.

#3 Requirements

  • Twitter OAuth2 credentials for fetching mentions.
  • Facebook Graph API credentials for reading posts and comments.
  • Azure OpenAI (GPT-4o) credentials for sentiment and summary generation.
  • Gmail OAuth2 credentials for automated email delivery.
  • Google Sheets OAuth2 credentials for error logging and tracking.

Environment Variables

  • TWITTER_API_KEY
  • FACEBOOK_GRAPH_TOKEN
  • AZURE_OPENAI_API_KEY
  • GMAIL_REPORT_RECIPIENTS
  • GOOGLE_SHEET_ERROR_LOG_ID

Target Audience

📈 Marketing and insights teams monitoring audience engagement. 💬 Social media managers analyzing public sentiment. 🧠 Data analysts exploring brand perception trends. 💡 PR and communications teams managing online reputation. 🧾 Operations or automation teams integrating AI analytics into dashboards.

Step-by-Step Setup Instructions

1️⃣ Connect all API credentials — Twitter, Facebook Graph, Azure OpenAI, Gmail, and Google Sheets. 2️⃣ Update your Twitter user ID and Facebook Page ID in the respective nodes. 3️⃣ Confirm the merge and validation logic in the Merge Platform Datasets and Validate API Response nodes. 4️⃣ Check that your Azure OpenAI account has GPT-4o access enabled. 5️⃣ Verify the Gmail recipient and test the “Send Email Summary” node for delivery. 6️⃣ Link your Google Sheet with a tab named error log sheet to capture workflow exceptions. 7️⃣ Run the workflow once manually to validate each layer — data, AI response, email delivery. 8️⃣ Optionally, schedule it to run daily or weekly for automated sentiment insights. ✅

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Execute workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Configure GPT-4o Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatAzureOpenAi - lmChatAzureOpenAi
Config choices
Version 1

Block 3 - Configure GPT-4o Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatAzureOpenAi - lmChatAzureOpenAi
Config choices
Version 1

Block 4 - Fetch Recent Mentions (X API)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 5 - Fetch Recent Facebook Comments

Type / Role
n8n-nodes-base.facebookGraphApi - facebookGraphApi
Config choices
Version 1

Block 6 - Merge Platform Datasets

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 7 - Consolidate Mentions & Comments

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 8 - Perform Sentiment & Keyword Analysis

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.1

Block 9 - Parse AI Output to Structured JSON

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Generate Audience Sentiment Summary

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.1

Block 11 - Send Email Summary to Marketing Team

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 12 - Log Errors in Google Sheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 13 - Validate API Response Integrity

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 14 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note9

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Analyze social media sentiment & trends from Twitter & Facebook using GPT-4o
Complexity advanced
Nodes 23
Categories Market Research, AI Summarization
Author Rahul Joshi
Published 14 Nov 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/10826/10826.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Analyze social media sentiment & trends from Twitter & Facebook using GPT-4o do?

Description Gain real time audience intelligence with this cross platform AI Sentiment Analyzer for Twitter (X) and Facebook. This workflow consolidates mentions and comments, performs GPT 4o ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Market Research, AI Summarization use case.