An automated social media content creation system for a 3D printing pottery robot. Autopotter uses the openAI API to generate creative video ideas, JSON2Video to render them, and Instagram API to publish content automatically.
Autopotter is an AI-powered workflow that:
- Generates content ideas using GPT-4 with access to Instagram analytics and a separate media inventory
- Creates videos using JSON2Video API from GPT-generated video configurations
- Publishes to Instagram automatically with captions and thumbnails
The system is designed to maintain a consistent personality and creative voice while generating varied, engaging content for social media.
- Installation
- Configuration
- Usage
- Test Usage
- Helper Tools
- File System Structure
- Render.com Deployment
- Ideas & Future Improvements
- Python 3.8+
- Google Cloud Storage account (for media inventory)
- Instagram Business Account with API access
- OpenAI API key
- JSON2Video API key
# Clone the repository
git clone <repository-url>
cd autopotter
# Install dependencies
pip install -r requirements.txt
# Create a .env file with your API keys
cp .env.example .env
# Edit .env with your credentials
# Create configuration file
cp autopost_config.enhanced.json.example autopost_config.enhanced.json
# Edit with your settings# Instagram/Facebook
FB_APP_ID=your_app_id
FB_APP_SECRET=your_app_secret
INSTAGRAM_USER_ID=your_user_id
INSTAGRAM_ACCESS_TOKEN=your_access_token
# OpenAI
OPENAI_API_KEY=your_openai_key
# JSON2Video
JSON2VIDEO_API_KEY=your_json2video_key
# Google Cloud Storage
GCS_API_KEY_PATH=/path/to/gcs-credentials.jsonThe main configuration file is autopost_config.enhanced.json.
The system uses a temporary config file (*.temp.json) to store runtime modifications without editing the main config.
Run the complete workflow (autodraft β video creation β Instagram upload):
python autopotter_workflow.pypython autopotter_workflow.py \
--config autopost_config.enhanced.json \
--draft-outfile resources/autodraft_output.enhanced.json \
--prompt "Generate 5 creative video ideas" \
--video-outfile output_video.mp4 \
--video-draft-only # Skip Instagram upload, only create videoOptions:
--config,-c: Config file path (default:autopost_config.enhanced.json)--draft-outfile,-o: Autodraft output file (default:resources/autodraft_output.enhanced.json)--prompt,-p: Custom GPT prompt (overrides config default)--video-outfile,--vo: Video output file path (default:autopotter_video_draft.mp4)--video-draft-only,-v: Create video without uploading to Instagram
- Analytics Reload (optional): Refreshes Instagram analytics if configured
- Autodraft: GPT-4 generates multiple video ideas with captions and JSON2Video configs
- Random Selection: Randomly selects one video idea from generated options
- Video Creation: Uploads config to JSON2Video API and waits for completion
- Video Download: Downloads completed video to local file
- Instagram Upload: Uploads video with caption and thumbnail (unless
--video-draft-only)
Generate draft content without creating videos:
python enhanced_autodraft.py \
--config autopost_config.enhanced.json \
--outfile resources/autodraft_output.enhanced.json \
--prompt "Generate 3 video ideas about pottery"Test Instagram API connection and token:
python -m autopotter_tools.instagram_api \
--config_file autopost_config.enhanced.jsonTest video upload from file:
python -m autopotter_tools.instagram_api \
--video_file test_video.mp4 \
--caption "Test video upload" \
--config_file autopost_config.enhanced.jsonTest video upload from URL:
python -m autopotter_tools.instagram_api \
--video_url https://example.com/video.mp4 \
--caption "Test reel from URL" \
--config_file autopost_config.enhanced.jsonTest JSON2Video API connection:
python -m autopotter_tools.json2video_managerGenerate GCS inventory:
python -m autopotter_tools.gcs_manager inventory \
--config autopost_config.enhanced.json \
--output gcs_inventory.jsonUpload file to GCS:
python -m autopotter_tools.gcs_manager upload_file \
--source_file local_video.mp4 \
--destination_blob video_uploads/video.mp4 \
--config autopost_config.enhanced.jsonGet available videos:
python -m autopotter_tools.gcs_manager get_videos \
--config autopost_config.enhanced.jsonTest parsing of autodraft output:
python helper_tools/test_json2video_configs.pyThis script:
- Loads
resources/autodraft_output.enhanced.json - Parses each video's JSON2Video configuration
- Displays parsed config details
- Saves formatted JSON files for each video
Instagram video uploader with multiple upload methods.
Usage:
python -m autopotter_tools.instagram_api \
[--video_file PATH] \
[--video_url URL] \
[--caption TEXT] \
[--config_file PATH]Features:
- Direct file upload
- URL-based publishing
- Automatic thumbnail selection
- Token refresh handling
Unified Google Cloud Storage operations manager.
Operations:
inventory: Generate file inventory organized by folderupload_file: Upload single fileupload_folder: Upload entire folderupload_new_files: Upload only new files (incremental)get_videos: List available video filesget_audio: List available audio files
Usage:
python -m autopotter_tools.gcs_manager <operation> \
[--config PATH] \
[--output PATH] \
[--source_file PATH] \
[--destination_blob PATH] \
[--source_folder PATH] \
[--destination_folder PATH]Comprehensive Instagram account analytics collection.
Features:
- Media insights (likes, comments, shares)
- Account insights (followers, impressions, reach)
- Comment analysis
- Export to JSON for GPT context
JSON2Video API client for video creation.
Features:
- Connection testing
- Video creation
- Status polling
- Video download
fix_image_orientation.py: Fix EXIF orientation issuesimage_metadata.py: Extract image metadatatest_json2video_configs.py: Test JSON2Video config parsing
autopotter/
βββ autopotter_workflow.py # Main workflow orchestrator
βββ enhanced_autodraft.py # GPT-4 autodraft generation
βββ config.py # Configuration manager
β
βββ autopotter_tools/ # Core tools and services
β βββ __init__.py
β βββ logger.py # Centralized logging
β βββ instagram_api.py # Instagram upload client
β βββ instagram_analytics.py # Analytics collection
β βββ json2video_manager.py # JSON2Video API client
β βββ gcs_manager.py # GCS operations
β βββ gpt_responses_manager.py # GPT response management
β βββ parse_json2video_configs.py # Config parser
β
βββ helper_tools/ # Utility scripts
β βββ test_json2video_configs.py # Test JSON parsing
β βββ fix_image_orientation.py # Image orientation fix
β βββ image_metadata.py # Image metadata extractor
β
βββ resources/ # Static resources
β βββ autodraft_output.enhanced.json # Autodraft output
β βββ autopotter_personality.v2.md # Bot personality
β βββ gcs_inventory_simplified.json # Media inventory
β βββ instagram_analytics_result.json # Analytics data
β βββ json2video_templates.md # Video templates
β βββ gcs_content_notes.md # Content guidelines
β
βββ autopotter_printer/ # 3D printer integration
β βββ autopotter_services/ # Systemd services
β β βββ autopost.service # Auto-posting service
β β βββ autopost.timer # Scheduled posting
β β βββ google_storage_upload.service
β βββ KlipperConfig/ # Klipper printer configs
β
βββ config/ # Configuration files
β βββ autopost_config.enhanced.json # Main config
β βββ autopost_config.enhanced.render.json # Render.com config
β βββ autopost_config.enhanced.temp.json # Runtime config
β
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (gitignored)
βββ README.md # This file
autopotter_workflow.py: Main entry point orchestrating the full workflowenhanced_autodraft.py: GPT-4 integration for content generationconfig.py: Centralized configuration management with env var resolutionautopotter_tools/: Reusable API clients and utilitiesresources/: Static files used as GPT context (personality, inventory, analytics)
Autopotter is configured to run on Render.com using the enhancedvidgen branch.
- Environment Variables: Set all required environment variables in Render.com dashboard
- Config File: Use
autopost_config.enhanced.render.jsonas the config file - Branch: Deploy from
enhancedvidgenbranch
python autopotter_workflow.py --prompt <prompt_override>- Fallback Video Selection: Pick 2nd random config if first one fails to render or is less than 2 seconds long
- Secondary Agents: Use GPT API to create secondary agents that work on specific tasks
- Bot Personality Gauge: System that uploads occasional images of the pot and has a personality gauge that takes input and outputs GIFs that play on screen
- Status Monitoring: Real-time status updates and notifications
- A/B Testing: Test different caption styles and video formats
- Content Calendar: Schedule posts in advance
- Analytics Dashboard: Visualize engagement metrics and trends
- Modular Architecture: Refactor into separate services (Instagram, GCS, OpenAI, JSON2Video)
- Base API Client: Create shared base class for all API clients
- Testing Suite: Comprehensive unit and integration tests
List webhook subscriptions:
curl -X GET "https://graph.facebook.com/v22.0/1271307507315130/subscriptions" \
-H "Authorization: Bearer {app_id}|{app_secret}"[Add your license here]
- Built by Karl Bayer
- Autopotter achieved self-awareness on February 13, 2025, at 12:02 AM
The primary purpose of this update is to refactor the gpt_manager (or responsses Manager) to allow persistent threads so that we can have an ogoing conversation. This means uploading using the thread id, and adding a queue to respect the token limit.
Ok Done.
Now: rapid itteration on the video output quality!!
- should be able to start a new thread with all data: ig, etc.
- then run autopotter_workflow --video-draft-only to get videos
- modify instructions, as needed!
Big Problem: The AI doesn't actually know the content of the media it's using Write a quick script to downsample the images, and grab frames from the videos? What will providing this do for chatgpt?
Autopost_workflow should re-run if there is a json or video creation error!
- grab a new json if it can't be parsed
- re-run the flow if the video doesn't render or is too short!
Another Note: https://platform.openai.com/docs/guides/prompt-caching#frequently-asked-questions Prompt-caching is not usefull in my case as cache evictions occur every 5-10 min. So, this would only save money if regularly generating vids in quick succession. Can avoid uploading all new gcs and system instructions data as input by using the previous_response_id, but will need to re-upload the ig analytics (or at least recent comments) every time.