N8N Tools - X (Twitter) Enhanced icon

N8N Tools - X (Twitter) Enhanced

Comprehensive X (Twitter) API v2 integration for N8N workflows

Overview

This node provides an enhanced integration with the X (formerly Twitter) API v2, enabling users to interact with various Twitter resources such as Tweets, Users, Timelines, Media, Spaces, Lists, Bookmarks, Direct Messages, Analytics, and Compliance features. Specifically for the Create Tweet operation under the Tweets resource, it allows users to post new tweets with text content up to 280 characters.

Common scenarios where this node is beneficial include:

  • Automating social media posting workflows by creating tweets programmatically.
  • Integrating tweet creation into larger automation pipelines, e.g., posting updates based on external triggers or data.
  • Managing Twitter content dynamically from other systems without manual intervention.

Practical example:

  • A marketing team uses this node in an n8n workflow to automatically tweet promotional messages whenever a new product is launched in their e-commerce system.

Properties

Name Meaning
Tweet Text The content of the tweet to be posted. Maximum length is 280 characters.
Include Private Metrics Whether to include private metrics in responses (requires elevated access).
Custom Fields Comma-separated list of additional custom fields to include in the response.
Custom Expansions Comma-separated list of expansions to include in the response for richer data.

Output

The node outputs JSON data representing the result of the Twitter API call corresponding to the operation performed. For the Create Tweet operation, the output JSON contains details about the newly created tweet, including its ID, text, and any metadata returned by the Twitter API.

If the node operation involves binary data (not applicable for Create Tweet), the binary output would represent media files or similar content.

Dependencies

  • Requires valid credentials for accessing the Twitter API via OAuth2 or API key authentication.
  • Requires a subscription and valid API key for the "N8N Tools API" service, which validates usage before making Twitter API calls.
  • The node depends on an internal helper class that wraps Twitter API v2 endpoints (TwitterApi).

Troubleshooting

  • Invalid subscription or API key error: If the node throws an error indicating invalid subscription or API key, verify that the N8N Tools API credentials are correctly configured and active.
  • Exceeded tweet length: Ensure the tweet text does not exceed 280 characters; otherwise, the Twitter API will reject the request.
  • Permission errors: Some operations require elevated access or specific permissions on the Twitter developer account; ensure your credentials have the necessary scopes.
  • Network or API errors: Transient network issues or Twitter API rate limits may cause failures; consider implementing retry logic or handling errors gracefully using the node's "Continue On Fail" option.

Links and References

Discussion