Animated data flow diagram

AI Tweet Generation Agent (OpenAI Davinci) & Airtable Logger

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

OpenAI Airtable

Overview

Unlock Automated Tweet Creation with this AI Agent

This n8n AI Agent streamlines your social media content creation by automatically generating tweets. Triggered manually, it first picks a random hashtag from a customizable list (e.g., "#techtwitter", "#n8n"). Then, it uses OpenAI's text-davinci-001 model to craft a concise tweet (under 100 characters) incorporating that hashtag. Finally, the generated tweet content and its corresponding hashtag are neatly organized and saved to your Airtable base, ready for review or scheduling.

This AI Agent has the tweet generation ability, allowing you to effortlessly produce social media content.

Key Features & Benefits

  • AI-Powered Tweet Generation: Leverages OpenAI's text-davinci-001 to create unique and relevant tweet drafts, showcasing its core 'tweet generation' skill.
  • Dynamic Hashtag Integration: Randomly selects from your predefined hashtag list to vary content and target different audiences.
  • Content Organization: Automatically saves generated tweets and hashtags to Airtable, creating a structured content repository.
  • Customizable: Easily modify the hashtag list and the OpenAI prompt to suit your specific content strategy.
  • Efficient Content Workflow: Reduces manual effort in brainstorming and drafting tweets, freeing up time for other strategic tasks.

Use Cases

  • B2C E-commerce: Quickly generate a variety of promotional tweets for different product categories using relevant hashtags, streamlining marketing efforts.
  • B2B SaaS: Populate a content calendar in Airtable with AI-generated tweets about product updates, industry insights, or upcoming webinars, enhancing social media consistency.
  • Solopreneurs & Founders: Maintain an active Twitter presence by automating the creation of engaging tweets, even with limited time and resources.
  • Content Marketers: Build a draft tweet bank in Airtable for campaigns, events, or evergreen content, ensuring a steady flow of social media updates and improving team productivity.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • OpenAI API Key with access to the text-davinci-001 model. Note: This model is older. For newer models like GPT-3.5 or GPT-4, you'll need to update the 'HTTP Request' node's URL and body parameters to use the Chat Completions API format.
  • Airtable account and API Key.
  • An Airtable Base with a table (the template uses 'main') containing at least two fields: one for 'Hashtag' (e.g., Single line text type) and one for 'Content' (e.g., Long text or Single line text type). The template's 'Set' node creates fields named 'Hashtag' and 'Content'.

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Configure Hashtags: In the 'FunctionItem' node, edit the Hashtags array within the JavaScript code to include your desired hashtags (e.g., ["#yourBrand", "#AI", "#automation"]).
  4. Configure OpenAI Connection (HTTP Request Node):
    • Select the 'HTTP Request' node.
    • For 'Authentication', choose 'Header Auth'.
    • For 'Credentials - Header Auth', click 'Create New Credential'.
    • Name it (e.g., "OpenAI API Key").
    • Add a header: Name = Authorization, Value = Bearer YOUR_OPENAI_API_KEY (replace YOUR_OPENAI_API_KEY with your actual key).
    • Save the credential.
    • The node is pre-configured for text-davinci-001. If you wish to use a newer model (e.g., GPT-4), you'll need to change the 'URL' to https://api.openai.com/v1/chat/completions and update the 'Body Parameters' to the Chat Completions JSON format (e.g., using model and messages fields).
  5. Configure Airtable Connection:
    • Select the 'Airtable' node.
    • For 'Credentials - Airtable API', click 'Create New Credential'.
    • Enter your Airtable API Key and save the credential.
    • In the 'Application' field, enter your Airtable Base ID (the template uses 'appOaG8kEA8FAABOr' as a placeholder; replace it with your actual Base ID).
    • In the 'Table' field, enter the name of your target table (the template uses 'main'; update if your table name is different).
    • Under 'Fields' > 'Input Data', ensure the 'Airtable Column (Internal Name)' values match your Airtable column names. The workflow passes {{$json["Hashtag"]}} and {{$json["Content"]}} from the 'Set' node. Map these to your corresponding Airtable columns (e.g., Airtable Column: TweetText, Value: ={{$json["Content"]}}).
  6. Review Data Mapping (Set Node): The 'Set' node is configured to prepare Hashtag and Content fields. Verify these names are used consistently in the Airtable node's field mapping.
  7. Save and activate the workflow.
  8. Manually trigger the workflow using the 'On clicking 'execute'' node to test its tweet generation and Airtable logging ability.

Tags:

AI AgentOpenAIContent GenerationTwitterAirtableSocial Media AutomationMarketing

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation