Back to Integrations
integrationGmail node
integrationX (Formerly Twitter) node

Gmail and X (Formerly Twitter) integration

Save yourself the work of writing custom integrations for Gmail and X (Formerly Twitter) and use n8n instead. Build adaptable and scalable Communication, HITL, and Marketing workflows that work with your technology stack. All within a building experience you will love.

How to connect Gmail and X (Formerly Twitter)

  • Step 1: Create a new workflow
  • Step 2: Add and configure nodes
  • Step 3: Connect
  • Step 4: Customize and extend your integration
  • Step 5: Test and activate your workflow

Step 1: Create a new workflow and add the first step

In n8n, click the "Add workflow" button in the Workflows tab to create a new workflow. Add the starting point – a trigger on when your workflow should run: an app event, a schedule, a webhook call, another workflow, an AI chat, or a manual trigger. Sometimes, the HTTP Request node might already serve as your starting point.

Gmail and X (Formerly Twitter) integration: Create a new workflow and add the first step

Step 2: Add and configure Gmail and X (Formerly Twitter) nodes

You can find Gmail and X (Formerly Twitter) in the nodes panel. Drag them onto your workflow canvas, selecting their actions. Click each node, choose a credential, and authenticate to grant n8n access. Configure Gmail and X (Formerly Twitter) nodes one by one: input data on the left, parameters in the middle, and output data on the right.

Gmail and X (Formerly Twitter) integration: Add and configure Gmail and X (Formerly Twitter) nodes

Step 3: Connect Gmail and X (Formerly Twitter)

A connection establishes a link between Gmail and X (Formerly Twitter) (or vice versa) to route data through the workflow. Data flows from the output of one node to the input of another. You can have single or multiple connections for each node.

Gmail and X (Formerly Twitter) integration: Connect Gmail and X (Formerly Twitter)

Step 4: Customize and extend your Gmail and X (Formerly Twitter) integration

Use n8n's core nodes such as If, Split Out, Merge, and others to transform and manipulate data. Write custom JavaScript or Python in the Code node and run it as a step in your workflow. Connect Gmail and X (Formerly Twitter) with any of n8n’s 1000+ integrations, and incorporate advanced AI logic into your workflows.

Gmail and X (Formerly Twitter) integration: Customize and extend your Gmail and X (Formerly Twitter) integration

Step 5: Test and activate your Gmail and X (Formerly Twitter) workflow

Save and run the workflow to see if everything works as expected. Based on your configuration, data should flow from Gmail to X (Formerly Twitter) or vice versa. Easily debug your workflow: you can check past executions to isolate and fix the mistake. Once you've tested everything, make sure to save your workflow and activate it.

Gmail and X (Formerly Twitter) integration: Test and activate your Gmail and X (Formerly Twitter) workflow

✨🤖Automate Multi-Platform Social Media Content Creation with AI

Automate Multi-Platform Social Media Content Creation with AI

Who is this for?
Social Media Managers and Digital Marketers seeking to streamline content production across 7+ platforms (X/Twitter, Instagram, LinkedIn, Facebook, TikTok, Threads, YouTube Shorts) using AI-powered automation.

What problem does this solve?
Creating platform-optimized content at scale while maintaining brand consistency across multiple channels, reducing manual work by 80% through AI generation and automated publishing.

What this workflow does
AI Content Generation:
Uses GPT-4/Gemini to create platform-specific posts
Automatically generates hashtags, CTAs, and emoji placement
Supports image/video suggestions and image creation using OpenAI or Pollinations.ai
Uses SERP api to search for relavent content

Approval Workflow:
Sends formatted HTML emails for human review
Implements double-approval system with Gmail integration

Cross-Platform Publishing:
One-click deployment to:
Instagram/Facebook (via Graph API)
X/Twitter (Official API)
LinkedIn (Sales Navigator integration)

Setup
Credentials:
OpenAI API key
Google Gemini API
Social media platform tokens (X, LinkedIn, Facebook)
ImgBB for image hosting
Gmail
SERP API
Telegram

Configuration:
Update all "your-unique-id" placeholders in API nodes
Set email recipients in Gmail nodes
Customize AI prompts

Customization:
Adjust character limits per platform
Modify approval thresholds
Add/remove social platforms as needed

How to customize
Content Style**: Edit prompt templates in the "Social Media Content Factory" agent node
Approval Process**: Modify email templates
Analytics**: Connect to Google Sheets for performance tracking
Image Generation**: Switch between Pollinations.ai/DALL-E/Midjourney

Nodes used in this workflow

Popular Gmail and X (Formerly Twitter) workflows

+8

✨🤖Automate Multi-Platform Social Media Content Creation with AI

Automate Multi-Platform Social Media Content Creation with AI Who is this for? Social Media Managers and Digital Marketers seeking to streamline content production across 7+ platforms (X/Twitter, Instagram, LinkedIn, Facebook, TikTok, Threads, YouTube Shorts) using AI-powered automation. What problem does this solve? Creating platform-optimized content at scale while maintaining brand consistency across multiple channels, reducing manual work by 80% through AI generation and automated publishing. What this workflow does AI Content Generation: Uses GPT-4/Gemini to create platform-specific posts Automatically generates hashtags, CTAs, and emoji placement Supports image/video suggestions and image creation using OpenAI or Pollinations.ai Uses SERP api to search for relavent content Approval Workflow: Sends formatted HTML emails for human review Implements double-approval system with Gmail integration Cross-Platform Publishing: One-click deployment to: Instagram/Facebook (via Graph API) X/Twitter (Official API) LinkedIn (Sales Navigator integration) Setup Credentials: OpenAI API key Google Gemini API Social media platform tokens (X, LinkedIn, Facebook) ImgBB for image hosting Gmail SERP API Telegram Configuration: Update all "your-unique-id" placeholders in API nodes Set email recipients in Gmail nodes Customize AI prompts Customization: Adjust character limits per platform Modify approval thresholds Add/remove social platforms as needed How to customize Content Style**: Edit prompt templates in the "Social Media Content Factory" agent node Approval Process**: Modify email templates Analytics**: Connect to Google Sheets for performance tracking Image Generation**: Switch between Pollinations.ai/DALL-E/Midjourney
+9

✨🩷Automated Social Media Content Publishing Factory + System Prompt Composition

Social Media Content Publishing Factory for Streamlined Content Creation Across Platforms Who is this for? This workflow is designed for content creators, social media managers, and marketing teams who need to efficiently create and publish content across multiple social media platforms. It's perfect for businesses looking to maintain a consistent presence across X (Twitter), Instagram, Facebook, LinkedIn, Threads, and YouTube Shorts without spending hours crafting platform-specific content manually. What problem is this workflow solving? Creating tailored content for different social media platforms is time-consuming and requires understanding each platform's unique requirements and audience expectations. This workflow solves the challenge of: Maintaining consistent messaging across platforms while respecting platform-specific formats Generating optimized content that follows best practices for each platform Creating accompanying visuals without graphic design skills Streamlining the approval process before publishing Reducing the time spent on repetitive content creation tasks What this workflow does This automated content factory takes your content idea and transforms it into platform-optimized posts for all major social media channels. The workflow: Accepts your content idea or topic through a chat interface Leverages AI to generate tailored content for each platform (X/Twitter, Instagram, Facebook, LinkedIn, Threads, YouTube Shorts) Creates appropriate images using AI image generation Sends content for approval via email before publishing Publishes approved content to selected platforms Maintains chat memory to improve future content generation Setup Connect your social media platform credentials (X/Twitter, Instagram, Facebook, LinkedIn) Set up your email account for the approval process Configure your OpenAI API key for AI content generation Update the image generation service credentials (Pollinations.ai is used by default) Customize the system prompts and schemas in the Google Docs nodes with your brand voice and content requirements How to customize this workflow to your needs Modify the system prompts in the Google Docs nodes to match your brand voice and content strategy Adjust the social media schemas to include specific fields relevant to your content Update the approval process to include additional stakeholders if needed Add or remove social media platforms based on your marketing strategy Customize the image generation prompts to better match your visual branding Integrate with your existing content calendar or CRM systems This workflow eliminates the need to manually craft different versions of the same content for each platform, saving hours of work while ensuring your social media presence remains consistent and optimized for maximum engagement.
+4

Generate Content Strategy Reports Analyzing Reddit, YouTube & X with Gemini

Description This workflow provides a powerful AI assistant for content creators, book editors, and marketers. It automates the collection and analysis of trending discussions from Reddit, YouTube, and X (Twitter), generating insightful topic reports. This frees you from hours of tedious data compilation, allowing you to make faster, more accurate topic decisions based on deep AI analysis. How it works This workflow simulates the complete research process of a strategic editor: Initiate & Collect: A user submits a keyword via a public Form Trigger. The workflow then automatically fetches relevant, trending content in parallel from the official APIs of Reddit, YouTube, and X (Twitter). Multi-stage AI Processing & Analysis: The workflow utilizes a layered AI pipeline to process the data. First, a lightweight Gemini model in the AI Pre-filter Content node rapidly screens the vast amount of content to filter out noise. Next, a more powerful Gemini Pro model in the AI Deep Analysis node performs a detailed, structured analysis on each high-value item, extracting summaries, sentiment, and key arguments. Finally, a "strategist" AI model in the AI Synthesize Final Report node aggregates all analyses to generate the comprehensive final topic report in HTML. Multi-Channel Report Distribution: The workflow distributes the final report to multiple channels based on pre-defined templates. The Send Gmail Report node sends the complete HTML report. The Send Feishu Notification node sends a concise summary card to a group chat. Meanwhile, the Archive to Google Sheets node archives key data. Setup Steps This workflow takes approximately 20-30 minutes to set up, with most of the time spent connecting your accounts. Connect Your API Accounts: In the n8n Credentials section, you will need to prepare and connect credentials for the following services: Google: For the Gemini AI model, Gmail sending, and Google Sheets archiving. This requires a Google Cloud API Key and OAuth2 credentials. Reddit: For fetching Reddit posts. This requires a Reddit account with OAuth2 configured in n8n to allow searches. YouTube: For collecting YouTube videos. You'll need to enable the YouTube Data API v3 in your Google Cloud Console and get an API Key. Twitter: For the official Twitter node, requiring a free developer account and an App with v2 API access. Configure Output Channels: In the final nodes (Send Gmail Report, Send Feishu Notification, Archive to Google Sheets), update the recipient email address, the Feishu bot's Webhook URL, and the target spreadsheet ID to match your own. Activate and Share the Trigger: Activate the workflow. The first Form Trigger node will automatically generate a public URL. Share this link with your team members to let them start using the tool.

Daily Competitor Tweet Summarizer with X API, GPT-5-Nano, and Gmail Delivery

Automated Daily Competitor Tweet Summarizer with X API, GPT-5-Nano, and Gmail Stay on top of your competition with this powerful n8n workflow that automatically fetches and summarizes your competitors’ latest tweets every day. Using the official X (formerly Twitter) API and OpenAI's GPT-5-Nano model, this template extracts insights from public tweets and sends concise summaries directly to your Gmail inbox. Ideal for marketing teams, product managers, PR professionals, and competitive intelligence analysts, this solution turns noisy social feeds into clear, actionable summaries—automated and customized to your needs. Features Daily automation: Fetches competitor tweets every 24 hours using X API AI summarization: Uses GPT-5-Nano to highlight key insights and themes Smart filtering: Cleans and filters tweets for relevance before summarizing Email delivery: Sends summaries to Gmail (or your team’s inbox) Fully customizable: Modify schedules, accounts, and integrations as needed Setup Instructions Get API Keys: X API (Bearer Token) – from developer.x.com OpenAI API Key – from platform.openai.com Gmail OAuth2 credentials (via Google Cloud Console) Configure in n8n: Import the workflow Add credentials under the "Credentials" tab Set target X usernames and schedule Customize Delivery (Optional): Set email subject, recipients Add additional integrations (e.g., Slack, Notion, Sheets) How It Works Trigger: A daily cron node initiates the workflow. Fetch User ID: The workflow uses the X API to retrieve the user ID based on the provided username. This step is necessary because the tweet retrieval endpoint requires a user ID, not a username. Fetch Tweets: Using the extracted user ID, the workflow queries the X API for recent tweets from the selected account. Clean Data: Filters out replies, retweets, and any irrelevant content to ensure only meaningful tweets are summarized. Summarize: GPT-4 processes the cleaned tweet content and generates a concise, insightful summary. Send Email: The Gmail node sends the final summary to your inbox or chosen recipient. Use Cases Track competitor announcements and marketing messages Automate daily social media briefs for leadership Monitor trends in your industry effortlessly Keep your team aligned with market developments Requirements Valid X API credentials (Bearer token) OpenAI API key Gmail OAuth2 credentials Access to n8n (cloud or self-hosted) Delivery Options While Gmail is the default, you can easily extend the workflow to integrate with: Slack Notion Google Sheets Webhooks Any supported n8n integration Automate your competitive intelligence process and stay informed—without lifting a finger.
+43

Explore n8n Nodes in a Visual Reference Library

WATCH THE n8n STARTER GUIDE 👇 This template is featured in the n8n Starter Guide series. The template is free, but comes with two additional PDFs and a Quick Start video if you grab the full download pack on gumroad. How it works This template is a visual map of many useful n8n nodes. It groups nodes like Triggers, AI tools, and App connectors onto the canvas. Explore the sections to learn about different nodes and easily copy them for your own workflows. It acts as a handy visual reference guide. Set up steps • Setup takes about 5 minutes. • Import the template into your n8n instance. • Explore the node categories visually on the canvas. • A Quick Start video is included in the download pack, along with a prompts PDF and PDF with links to other awesome n8n templates here on the n8n template gallery.
+2

Auto-Publish Latest News on X with AI Content Generation using Keywords and Bright Data

📰 Publish Latest News on X and Other Social Media Platforms Using Keyword A comprehensive n8n automation that fetches the latest news based on keywords, generates AI-powered social media content, and automatically publishes to X (Twitter) with complete tracking and notification systems. 📋 Overview This workflow provides a professional news publishing solution that automatically discovers breaking news, creates engaging social media content using AI, and publishes to X (Twitter) with comprehensive tracking. Perfect for news organizations, content creators, social media managers, and businesses wanting to stay current with automated news sharing. The system uses BrightData's Google News dataset, OpenAI's GPT-4o for content generation, and multi-platform integration for complete automation. ⭐ Key Features 📝 Form-Based Input**: Clean web form for keyword and country submission 📰 Real-Time News Fetching**: BrightData Google News integration for latest articles 🤖 AI Content Generation**: GPT-4o powered tweet creation with hashtags 📱 Auto X Publishing**: Direct posting to X (Twitter) with URL tracking 📊 Complete Tracking**: Google Sheets logging of all published content 🔔 Email Notifications**: Success alerts with tweet links 🌍 Multi-Country Support**: Localized news for US, India, UK, Australia ⚡ Status Monitoring**: Real-time progress tracking with retry logic 🛡 Error Handling**: Robust error management and validation 🔄 Loop Management**: Intelligent waiting for news processing completion 🎯 What This Workflow Does Input: News Name**: Keyword or topic for news search (required) Country**: Target country for localized news (dropdown: US/IN/GB/AU) Processing: Form Submission: Captures news keyword and target country News Triggering: Initiates BrightData Google News scraping job Status Monitoring: Checks scraping progress with intelligent retry loop Data Retrieval: Fetches latest news articles when ready AI Content Creation: Generates engaging tweet content using GPT-4o Social Publishing: Posts content to X (Twitter) automatically URL Generation: Creates direct tweet links for tracking Data Logging: Saves content and URLs to Google Sheets Email Notification: Sends success confirmation with tweet link Completion: Workflow ends with full audit trail 📋 Output Data Points | Field | Description | Example | | :------------ | :---------------------------------- | :----------------------------------------------------------------------------------------------------- | | TweetMessage | AI-generated social media content | "Breaking: AI revolution transforming healthcare with 40% efficiency gains. New study shows promising results in patient care automation. #AI #Healthcare #Innovation #TechNews #US" | | TweetURL | Direct link to published tweet | https://twitter.com/i/web/status/1234567890123456789 | 🛠️ Setup Instructions Prerequisites: n8n instance (self-hosted or cloud) X (Twitter) account with API v2 access OpenAI account with GPT-4o access Gmail account for notifications Google account with Sheets access BrightData account with Google News dataset access Basic understanding of social media automation Step 1: Import the Workflow Copy the JSON workflow code from the provided file. In n8n, click "+ Add workflow". Select "Import from JSON". Paste the workflow code and click "Import". The workflow will appear with all nodes properly connected. Step 2: Configure API Credentials X (Twitter) API Setup: Create X Developer Account at developer.twitter.com. Create new app and generate API keys. In n8n: Credentials → + Add credential → Twitter OAuth2 API. Add your Twitter API credentials: API Key API Secret Key Bearer Token Access Token Access Token Secret Test the connection with a sample tweet. OpenAI API Configuration: Get API key from platform.openai.com. Ensure GPT-4o model access is available. In n8n: Credentials → + Add credential → OpenAI API. Add your OpenAI API key. Verify model access in the "OpenAI Chat Model" node. Gmail Integration: Create "Gmail OAuth2" credential. Follow OAuth setup process. Grant email sending permissions. Test with sample email. BrightData News API: The workflow uses pre-configured token: 5662edde-6735-4c5d-a6c6-693043a5a9a5. Dataset ID: gd_lnsxoxzi1omrwnka5r (Google News). Verify access to Google News dataset. Test API connection. Google Sheets Integration: Create "Google Sheets OAuth2 API" credential. Complete OAuth authentication. Grant read/write permissions. Test connection. Step 3: Configure Google Sheets Integration Create Google Sheets Structure: Sheet Name: "Publish Latest News on Social Media Platforms Using Keyword" Tab: "Data" (default) Columns: Tweet Message: AI-generated content posted to X Tweet URL: Direct link to published tweet Sheet Configuration: Create new Google Sheet or use existing one. Add the required column headers. Copy Sheet ID from URL: https://docs.google.com/spreadsheets/d/SHEET_ID_HERE/edit. Current configured Sheet ID: 1koxNrwdeuaSBdREuKc7JQh3d9blEk0sQDJ8VgVLjPOo. Update Workflow Settings: Open "Google Sheets" node. Replace Document ID with your Sheet ID. Select your Google Sheets credential. Choose "Data" sheet/tab. Verify column mapping is correct. Step 4: Configure Form Interface Form Settings: Open "On form submission" node. Form configuration: Title: "News Publisher" Description: "publish latest news to direct social media" Fields: News Name (text, required) Country (dropdown: US, IN, GB, AU, required) Webhook URL: Copy webhook URL from form trigger node. Current webhook ID: 8d320705-688c-4150-a393-cf899d2bbb52. Test form accessibility and submission. Step 5: Configure Email Notifications Gmail Setup: Open "Gmail" node. Update recipient email: [email protected]. Email template includes: Success confirmation Direct tweet link Professional formatting Test email delivery. Step 6: Test the Workflow Sample Test Data: Use these examples for testing: | News Name | Country | Expected Results | | :-------------------- | :------ | :------------------------------------------------- | | artificial intelligence | US | Latest AI news with US-specific hashtags | | cricket world cup | IN | Sports news with India-focused content | | brexit update | GB | UK political news with British hashtags | | bushfire news | AU | Australian environmental news | Testing Process: Activate the workflow (toggle switch). Navigate to the webhook form URL. Submit test data. Monitor execution progress: News fetching (30-60 seconds) AI content generation (10-15 seconds) X publishing (5-10 seconds) Sheet update and email (5 seconds) Verify results in all platforms. 📖 Usage Guide Using the Form Interface Navigate to the webhook URL provided by the form trigger. Enter news keyword or topic (e.g., "climate change", "stock market", "technology"). Select target country from dropdown. Click submit and wait for processing. Check email for success notification with tweet link. Example Inputs to Test | News Name | Country | Expected | | :-------------------------------- | :------ | :----------------------------------------------------- | | "artificial intelligence breakthrough" | "US" | Latest AI developments with tech hashtags | | "football premier league" | "GB" | UK football news with sports hashtags | | "stock market updates" | "IN" | Indian market news with finance hashtags | | "hollywood movies" | "AU" | Entertainment news with Australian perspective | Country-Specific Considerations United States (US)**: Focus on national news and global impact. Hashtags: #USA, #American, #Breaking, #News. Time zone considerations for optimal posting. India (IN)**: Emphasis on regional relevance. Hashtags: #India, #Indian, #News, #Breaking. Cultural context in content generation. United Kingdom (GB)**: British perspective and terminology. Hashtags: #UK, #British, #News, #Breaking. Focus on European context. Australia (AU)**: Australian angle and regional focus. Hashtags: #Australia, #Australian, #News, #Breaking. Pacific region context. 📊 Reading the Results Google Sheets Data The output sheet contains: Complete tweet content with hashtags and formatting. Direct tweet URLs for easy access and sharing. Chronological record of all published content. Audit trail for content management. Email Notifications Success emails include: Confirmation that content was published. Direct link to view the tweet. Professional formatting for easy reference. X (Twitter) Posts Published content features: AI-optimized messaging within 260 character limit. Relevant hashtags based on topic and country. Engaging format designed for social media. Professional tone suitable for news sharing. 🔧 Customization Options Expanding Social Media Platforms Add more platforms to the publishing workflow: // Add LinkedIn publishing { "node": "LinkedIn", "type": "n8n-nodes-base.linkedin", "parameters": { "text": "={{ $json.output }}", "additionalFields": {} } } // Add Facebook posting { "node": "Facebook", "type": "n8n-nodes-base.facebook", "parameters": { "pageId": "YOUR_PAGE_ID", "message": "={{ $json.output }}" } }

Build your own Gmail and X (Formerly Twitter) integration

Create custom Gmail and X (Formerly Twitter) workflows by choosing triggers and actions. Nodes come with global operations and settings, as well as app-specific parameters that can be configured. You can also use the HTTP Request node to query data from any app or service with a REST API.

Gmail supported actions

Add Label
Delete
Get
Get Many
Mark as Read
Mark as Unread
Remove Label
Reply
Send
Send and Wait for Response
Create
Delete
Get
Get Many
Create
Delete
Get
Get Many
Add Label
Delete
Get
Get Many
Remove Label
Reply
Trash
Untrash

X (Formerly Twitter) supported actions

Create
Send a direct message to a user
Add Member
Add a member to a list
Create
Create, quote, or reply to a tweet
Delete
Delete a tweet
Like
Like a tweet
Retweet
Retweet a tweet
Search
Search for tweets from the last seven days
Get
Retrieve a user by username

FAQs

  • Can Gmail connect with X (Formerly Twitter)?

  • Can I use Gmail’s API with n8n?

  • Can I use X (Formerly Twitter)’s API with n8n?

  • Is n8n secure for integrating Gmail and X (Formerly Twitter)?

  • How to get started with Gmail and X (Formerly Twitter) integration in n8n.io?

Need help setting up your Gmail and X (Formerly Twitter) integration?

Discover our latest community's recommendations and join the discussions about Gmail and X (Formerly Twitter) integration.
jake chard
Jan Koch
lexgabrees
Andrey Khokhlov
Paul Kennard

Looking to integrate Gmail and X (Formerly Twitter) in your company?

Over 3000 companies switch to n8n every single week

Why use n8n to integrate Gmail with X (Formerly Twitter)

Build complex workflows, really fast

Build complex workflows, really fast

Handle branching, merging and iteration easily.
Pause your workflow to wait for external events.

Code when you need it, UI when you don't

Simple debugging

Your data is displayed alongside your settings, making edge cases easy to track down.

Use templates to get started fast

Use 1000+ workflow templates available from our core team and our community.

Reuse your work

Copy and paste, easily import and export workflows.

Implement complex processes faster with n8n

red iconyellow iconred iconyellow icon