Automated Twitter Sentiment Analysis & Slack Alert Workflow

High-Level Summary

This workflow automatically monitors Twitter (X) for posts containing a specific keyword, analyzes their sentiment using OpenAI, and takes conditional actions based on the result. It is designed to help social media managers, marketers, and customer support teams track brand mentions or event-related tweets in real-time. The workflow fetches tweets via the Apify X Posts Search API, checks for duplicates in a Google Sheet, performs sentiment analysis with GPT-4o-mini, and then either generates a positive reply, sends a Slack alert for negative tweets, or logs neutral tweets for future reference. All data is stored in Google Sheets for auditability.

Step-by-Step Node Breakdown

  1. Schedule Trigger — Runs the workflow every 6 hours. No auth required. The trigger is set to a 6-hour interval, ensuring regular monitoring without overwhelming API quotas.

  2. Request for Twitter Post via Apify — Makes a POST request to the Apify API to search for tweets. API Key auth using query parameter token. It sends a JSON body with the query "LaraconIn", fetching 5 latest English tweets. This node will continue on error if the API fails.

  3. Get Requested Post from Apify — Makes a GET request to retrieve the results from the Apify run. API Key auth using query parameter token. It fetches the dataset items from the most recent Apify run.

  4. Set Field for Loop — Renames incoming JSON fields to standardized names (id, tweet_url, tweet_text). No auth. This ensures downstream nodes receive consistent field names regardless of API response structure.

  5. Loop Over Items — Iterates over each tweet item. No auth. This split-in-batches node processes tweets one by one, enabling per-tweet actions.

  6. Get Post Data — Queries Google Sheets to check if a tweet already exists. OAuth2 auth (Google Sheets). It looks up the tweet ID in column "ID" to detect duplicates.

  7. If Duplicate — Checks if the tweet ID exists in the sheet. No auth. If the ID exists (true branch), the item is skipped to avoid duplicates. If not (false branch), the tweet proceeds to sentiment analysis.

  8. OpenAI Chat Model — Provides the GPT-4o-mini language model for sentiment analysis. API Key auth (OpenAI). This node supplies the AI model to the Sentiment Analyst agent.

  9. Structured Output Parser — Parses the sentiment result into structured JSON with a "category" field. No auth. It expects output in the format {"category": "neutral"} to ensure consistent data for the switch node.

  10. Sentiment Analyst — Analyzes tweet text sentiment using GPT-4o-mini. No auth (uses the OpenAI Chat Model node). It classifies each tweet as Positive, Negative, or Neutral based on the system prompt.

  11. Switch According Analyst — Routes tweets based on their sentiment category. No auth. Three outputs:

    • Positive: Routes to OpenAI for reply generation
    • Negative: Routes to Slack for alerting
    • Neutral: Routes directly to Google Sheets logging
  12. OpenAI — Generates a user-style reply for positive tweets. API Key auth (OpenAI). It uses GPT-4o-mini to craft a short, friendly, emoji-free reply under 160 characters, directed at the original poster.

  13. Send negative post message on slack — Sends a Slack message for negative tweets. OAuth2 auth (Slack). Posts to the #website-uptime channel with the tweet URL and a notification that action may be needed.

  14. Add Post Data — Writes all tweet data back to Google Sheets. OAuth2 auth (Google Sheets). Appends or updates the row with Tweet ID, URL, text, sentiment, and the generated reply (if any). Matching is done on the ID column.

Setup Instructions

To use this workflow, you need accounts and credentials for the following services:

Prerequisites

  1. Apify API Token (free tier available) — Sign up at apify.com and get your token from Settings > API & Integrations. Replace api_key in both HTTP Request URLs with your actual token.
  2. OpenAI API Key — Sign up at platform.openai.com and create a project API key with access to GPT-4o-mini.
  3. Google Sheets API — You need a Google Cloud Project with the Sheets API enabled. n8n provides OAuth2 credential setup for Google Sheets.
  4. Slack App — Create a Slack app at api.slack.com with the chat:write scope and install it to your workspace. Channel ID C090F70N52M must be replaced with your actual channel.
  5. n8n instance — Self-hosted or cloud (n8n.io).

Configuration

  • Google Sheet: Create a sheet with columns: ID, TweetUrl, TweetText, Sentiment , Post Reply. Update the documentId and sheetName in both Google Sheets nodes.
  • Search Query: In the "Request for Twitter Post via Apify" node, change query from "LaraconIn" to your desired keyword/hashtag.
  • Schedule: Adjust the interval in the Schedule Trigger node as needed.

Use Cases & Variations

This workflow is highly adaptable. Consider these variations:

Use Cases

  • Brand Monitoring: Track your company name or product mentions on Twitter, instantly alerting customer support to negative tweets.
  • Event Tracking: Monitor hashtags for conferences (like #LaraconIn) to engage with attendees and gather feedback.
  • Competitor Analysis: Track competitor product launches or campaigns to understand public sentiment.

Customizations

  • Modify Sentiment Categories: Change the system prompt in Sentiment Analyst to detect urgency, spam, or specific topics.
  • Add More Outputs: Route positive tweets to a Slack celebration channel, or negative tweets to a ticketing system like Jira.
  • Different AI Models: Swap GPT-4o-mini for Claude or Gemini by changing the language model node.
  • Expand Data Sources: Replace Apify with other Twitter scrapers or RSS feeds from social media listening tools.
  • Add Human Review: Insert a manual approval step before sending replies to ensure brand safety.
15 nodesschedule triggerSocial Media
Split In BatchesOpen AIOutput Parser StructuredGoogle SheetsAgentSwitchSetSlack

Workflow JSON

{
  "name": "Twitter Monitoring Workflow",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -60,
        210
      ],
      "id": "8fa04bf9-68e5-43b7-81f2-ee5f2355abd9",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "={{ $('Set Field for Loop').item.json.tweet_text }}"
            },
            {
              "content": "=You are a professional Twitter social media user replying to the original poster (admin).\n\nAnalyze the sentiment of the tweet below. If the sentiment is positive, write a short, thoughtful reply **from a user's perspective**, directed to the person who posted it.\n\nThe reply should:\n- Show appreciation, agreement, or excitement\n- Be friendly, intelligent, and relevant to tech or AI fields\n- Use no emojis\n- Be under 160 characters\n- Address the original poster directly as a real person would\n\nTweet:\n\"\"\"\nuse a user prompt\n\"\"\"",
              "role": "system"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1380,
        -220
      ],
      "id": "dec03e00-a5fa-44eb-b269-b486259ac1aa",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "ga54eHkT3k6225Zq",
          "name": "OpenAi account"
        }
// ... truncated (copy to see full JSON)

How to Import This Workflow

  1. 1Copy the workflow JSON above using the Copy Workflow JSON button.
  2. 2Open your n8n instance and go to Workflows.
  3. 3Click Import from JSON and paste the copied workflow.

Don't have an n8n instance? Start your free trial at n8nautomation.cloud

Related Templates

AI Viral Video Creator from Telegram with Voice & Multi-Platform Posting

🚀 Automatically Generate and Publish Viral TikTok-Style Videos from a Simple Telegram Message This workflow transforms a single Telegram message containing a photo and a theme (caption) into a fully-produced, AI-generated talking-head video optimized for viral social media content. It leverages Perplexity for trend research, OpenAI GPT-4 for script and caption generation, ElevenLabs for realistic voice synthesis, and FAL.ai's VEED Fabric model to create a lip-synced avatar video from the photo. The final video, along with an engaging caption and relevant hashtags, is saved to Google Sheets for tracking and then automatically published to up to nine social media platforms—TikTok, YouTube, Instagram, LinkedIn, Facebook, Twitter (X), Threads, Pinterest, and Bluesky—via the Blotato integration. This is an end-to-end content creation pipeline perfect for creators, marketers, and businesses who want to maintain a consistent, high-frequency posting schedule without manual video editing. It reduces the time from idea to published video to under 5 minutes. 📋 Node-by-Node Breakdown Telegram Trigger (Telegram Bot Token) — Listens for incoming messages containing a photo and caption. The trigger activates on updates. No additional filtering is applied; every photo with a caption will start the workflow. Workflow Configuration (No auth) — A static Set node that stores API keys and configuration values (ElevenLabs API key, voice ID, FAL API key, and the Perplexity model name) as workflow variables for easy maintenance. Extract Photo and Theme (No auth) — Extracts the largest photo file ID from the Telegram message and the caption (or text) as the theme. Falls back to "viral content" if no caption is provided. Get Photo File from Telegram (Telegram Bot Token) — Uses the Telegram Bot API to download the photo file specified by the file ID extracted in the previous step. Build Public Image URL (No auth) — Uploads the downloaded photo to to obtain a publicly accessible URL. This URL is later used by FAL.ai's VEED Fabric model. Search Trends with Perplexity (Perplexity API key) — Sends a query to Perplexity AI asking for the top 3 current viral trends related to the user's theme. The model is configured dynamically from the workflow configuration node. Generate Script with GPT-4 (OpenAI API key) — Uses OpenAI GPT-4o-mini to generate a 30-second TikTok script based on the trends found by Perplexity and the original theme. The prompt enforces a hook in the first 2 seconds and conversational tone. ElevenLabs Voice Synthesis (API key in header) — Sends the generated script to ElevenLabs' text-to-speech API with the configured voice ID, producing an MP3 audio file. Uses header for authentication. Convert .mpga to .mp3 (No auth) — A JavaScript Code node that renames the binary audio file from to and sets the correct MIME type, ensuring compatibility with downstream nodes. Upload Audio to Public URL (No auth) — Uploads the MP3 audio to to make it publicly accessible for FAL.ai. FAL.ai Video Generation (API key in header) — Sends a request to FAL.ai's VEED Fabric 1.0 endpoint with the public image URL and audio URL to generate a talking-head lip-sync video at 480p resolution. Authentication uses the header with the FAL API key. Wait for VEED (No auth) — A Wait node that pauses execution for 10 minutes to allow the video generation to complete. The node uses polling via webhook (not active here) but is configured as a timed wait. Download VEED Video (API key in header) — Periodically queries the FAL.ai request status endpoint (using the request ID from the generation response) to retrieve the completed video URL. Generate Caption with GPT-4 (OpenAI API key) — A second OpenAI node that creates an engaging TikTok caption with trending hashtags based on the same theme and trends. Outputs only the caption text. Save to Google Sheets (Google Sheets OAuth2) — Appends a new row to a Google Sheet with columns: IDEA (original theme), CAPTION, AUDIO URL, IMAGE URL, VIDEO URL. The sheet and document ID are expected to be configured via resource locator or expression. Send a video (Telegram Bot Token) — Sends the generated video back to the original Telegram chat as a confirmation. Upload Video to BLOTATO (Blotato API key) — Uploads the video file to Blotato's media storage, obtaining a hosted URL for distribution. TikTok / YouTube / LinkedIn / Facebook / Instagram / Twitter (X) / Threads / Bluesky / Pinterest (Blotato API key) — Nine parallel Blotato nodes that each publish the video to their respective social media accounts. Each node uses pre-configured account IDs (list mode) and the generated caption. YouTube optionally sets the video to "private" and disables subscriber notifications. Merge1 (No auth) — A Choose Branch merge node that waits for all nine social media publishing branches to complete before continuing. Update Status to "DONE" (Google Sheets OAuth2) — Updates the corresponding row in the Google Sheet (matched by video URL) to set the STATUS column to "DONE". 🔧 Setup Instructions To use this workflow, you'll need the following accounts and API keys: Telegram — Create a bot via @BotFather and get the bot token. Use it in the Telegram Trigger and Telegram nodes. ElevenLabs — Sign up at elevenlabs.io, generate an API key, and clone or select a voice. Note the Voice ID. FAL.ai — Sign up at fal.ai, create an API key from the dashboard. The workflow uses the VEED Fabric 1.0 model – no separate VEED subscription is needed. Perplexity AI — Sign up at perplexity.ai, get an API key from settings. OpenAI — Sign up at platform.openai.com, create an API key with access to GPT-4o-mini. Google Sheets — Create a Google Sheet with the required columns (IDEA, URL IMAGE, URL AUDIO, URL VIDEO, CAPTION, STATUS). Set up Google Sheets OAuth2 credentials in n8n. Blotato — Sign up at blotato.com, get an API key from settings. Install the community node in n8n (Settings → Community Nodes). Connect each social media account within Blotato to obtain account IDs. tmpfiles.org — No account required; the service is used for temporary file hosting. After obtaining all keys, update the Workflow Configuration node with your values and configure credentials for each API node (Telegram, Perplexity, OpenAI, Google Sheets, Blotato). The sticky notes in the canvas provide step-by-step visual guidance. 💡 Use Cases & Variations Content Repurposing: The workflow can be adapted to repurpose a blog post or article into a short video by feeding the text as a theme. Brand Voice: Customize the ElevenLabs voice to match your brand's tone. Trend-Driven Campaigns: Use Perplexity with different prompts to focus on niche topics (e.g., "tech startups", "healthy recipes"). Platform-Specific Formatting: Modify the caption generation prompt to include platform-specific elements (e.g., LinkedIn professional tone, Twitter character limit). Scheduling: Add a Schedule Trigger to run the workflow periodically with pre-defined themes from a spreadsheet instead of Telegram. Analytics: Extend the Google Sheet with additional columns for engagement metrics by integrating with social media analytics APIs. This workflow is fully modular; you can remove any of the Blotato publishing nodes if you only need specific platforms.

35 nodes

AI-Powered Social Media Post Automation from Google Trends

AI-Powered Social Media Post Automation from Google Trends This workflow automatically generates and publishes social media posts based on trending Google search queries. It combines Google Trends data, AI content generation, and multi-platform publishing to keep your social channels active with relevant, engaging content without manual effort. The workflow runs twice daily (at 6 AM and 6 PM) and follows a pipeline: fetch trending keywords → select the best topic → generate a human-like post using Perplexity AI → publish to X (Twitter), Facebook, and LinkedIn → log the activity in Google Sheets. This is ideal for marketers, social media managers, and content creators who want to maintain a consistent posting schedule with minimal intervention. How It Works Schedule Trigger — Runs the workflow twice daily at 6 AM and 6 PM (no auth required). Google Trends (HTTP Request) — Fetches related queries from Google Trends via SerpAPI. Uses API Key auth (the parameter is passed as a query parameter). It retrieves rising queries for the keyword "ai agents" in the US over the last 3 days. 2 Most Trending (Set) — Extracts the top two rising queries from the Google Trends response and structures them into a clean JSON object with and keys. High search volume keywords (Code) — Filters the top related queries to include only those with an extracted value (search volume increase) greater than 30, and joins them into a comma-separated string. Choosing Topic (OpenAI) — Uses GPT-3.5-turbo to select the most relevant keyword from the two trending options, based on the client's SEO goals and trendiness. Requires OpenAI API key. Research Topic- Perplexity (HTTP Request) — Sends the chosen topic to Perplexity's API (sonar-pro model) to generate a complete LinkedIn post. Uses Header Auth (HTTP Header Auth) with your Perplexity API key. The prompt instructs the AI to write a human-like, engaging post with Unicode formatting, bullet points, and a call-to-action. Wait — Pauses for 10 seconds to ensure the AI generation is complete and to avoid rate limits. Split Out — Splits the AI-generated content from the Perplexity response into separate items for each social platform. X1 (Twitter) — Publishes the post to X (Twitter) using OAuth2 authentication. Facebook Graph API1 — Publishes the post to a Facebook Page using OAuth2 authentication. LinkedIn1 — Publishes the post to LinkedIn using Community Management authentication (OAuth2). Google Sheets2 — Appends or updates a row in Google Sheets with the topic, AI output, status, and date posted. Uses OAuth2 authentication. Setup Instructions To use this workflow, you'll need accounts and credentials for the following services: SerpAPI — Sign up at serpapi.com and get an API key. Replace in the Google Trends node. OpenAI — Create an API key at platform.openai.com. Add it as a credential in n8n. Perplexity — Get an API key from perplexity.ai and set it as an HTTP Header Auth credential. X (Twitter) — Create a Twitter app and obtain OAuth2 credentials. Facebook — Create a Facebook app and get a Page Access Token with permission. LinkedIn — Create a LinkedIn app and get a Community Management token. Google Sheets — Create a Google Cloud project, enable Sheets API, and set up OAuth2 credentials. Replace the document ID and sheet name in the Google Sheets node. After setting up credentials, update the Google Sheets document ID and sheet name, and configure the LinkedIn person ID (replace ). Use Cases and Variations Content Marketing — Automate daily posting of trending topics to multiple platforms, saving hours of manual research and writing. SEO Blogging — Modify the workflow to generate full blog posts instead of social media posts and publish to a CMS like WordPress. Multi-Client Management — Adapt the workflow to handle multiple clients by adding a loop or using a different Google Sheets row for each client. Custom Keywords — Change the parameter in the Google Trends node to target different niches or industries. Additional Platforms — Add more social media nodes (e.g., Instagram, Pinterest) by connecting them to the Split Out node. Human Review — Insert a manual approval step (e.g., using the Wait node or a Slack notification) before publishing to ensure content quality.

18 nodes

Cross-post YouTube Uploads to Facebook

Cross-post YouTube Uploads to Facebook This workflow provides a complete skeleton for a Cross-post YouTube Uploads to Facebook using n8n's AI nodes. It is triggered via a webhook, processes incoming data by splitting text, generating embeddings with OpenAI, storing and querying vectors in Pinecone, and finally running an Anthropic-powered agent to produce outputs. Results are logged to Google Sheets, and errors are sent to a Slack channel. Node-by-Node Breakdown Webhook Trigger (No auth) — Listens for incoming HTTP POST requests at a specified path (). This is the entry point; you can later change to a YouTube trigger or schedule. Text Splitter (No auth) — Splits incoming text into chunks of 400 characters with 40-character overlap (, ). Prepares data for embedding. Embeddings (OpenAI API Key auth) — Uses the model to generate vector embeddings for each text chunk. Pinecone Insert (Pinecone API Key auth) — Inserts the embeddings into a Pinecone index named . This stores the knowledge base. Pinecone Query (Pinecone API Key auth) — Queries the same Pinecone index to retrieve relevant vectors based on new incoming data. Vector Tool (No auth) — Wraps the Pinecone query into a tool that the AI agent can call to fetch context from the vector store. Window Memory (No auth) — Maintains a short-term conversational memory (buffer window) so the agent can reference previous interactions. Chat Model (Anthropic API Key auth) — Uses an Anthropic language model (e.g., Claude) to generate responses. Configured with no additional options. RAG Agent (No auth) — The central AI agent that orchestrates the workflow. It receives a system message "You are an assistant for Cross-post YouTube Uploads to Facebook" and can use the Vector Tool and Memory. Its output goes to the next node. Append Sheet (Google Sheets OAuth2) — Appends the agent's response (under column "Status") to a Google Sheet named "Log" in the spreadsheet specified by . The column mapping is defined below. Slack Alert (Slack OAuth2) — On error (connected to the output of the RAG Agent), sends a message to channel with the error text. Setup Instructions To use this workflow, you will need accounts and credentials for the following services: OpenAI – Generate an API key from platform.openai.com. Add it as an n8n credential of type "OpenAI API". Anthropic – Obtain an API key from console.anthropic.com and create an "Anthropic API" credential. Pinecone – Create a Pinecone account and index named . Get the API key and environment, then set up a "Pinecone API" credential in n8n. Google Sheets – Enable the Google Sheets API in your Google Cloud project. Create OAuth2 credentials (desktop app or web) and add them as a "Google Sheets OAuth2" credential in n8n. Slack – Create a Slack app with the scope. Install it to your workspace and add the bot token as a "Slack OAuth2" credential. After setting up credentials, update the workflow: Replace in the Google Sheets node with your actual spreadsheet ID. Adjust the Pinecone index name if you created a different one. Modify the webhook path or replace it with a scheduled trigger or YouTube trigger. Use Cases and Variations Cross-posting – Replace the webhook with a YouTube trigger (e.g., "When a video is published") and add an HTTP Request node to post to the Facebook Graph API. Use the RAG Agent to generate captions or summaries. Customer Support Chatbot – Change the webhook to a manual form or chat trigger. Load FAQ documents into Pinecone and let the agent answer user queries. Content Summarization – Feed long articles via webhook, have the agent summarize them, and log the summary to Google Sheets. Error Monitoring – Replace the webhook with a monitoring tool (e.g., Sentry) and let the AI analyze error logs stored in Pinecone. This workflow is highly modular: you can swap the AI model (e.g., use OpenAI Chat instead of Anthropic), change the vector store (e.g., Qdrant or Weaviate), or add more tools like web search or calendar access.

12 nodes

Ready to automate with n8n?

Get affordable managed n8n hosting with 24/7 support.