Back to Omi

๐Ÿฆ Twitter Voice Poster for OMI

plugins/omi-twitter-app/README.md

3.0.0-Android-App8.7 KB
Original Source

๐Ÿฆ Twitter Voice Poster for OMI

Voice-activated Twitter posting through your OMI device. Simply say "Tweet Now" followed by your message, and it will be automatically posted to Twitter!

Live Demo: omi-twitter.up.railway.app

โœจ Features

  • ๐ŸŽค Voice-Activated - Say "Tweet Now" and speak your message
  • ๐Ÿง  AI-Powered - Collects 3 segments, intelligently extracts and cleans your tweet
  • ๐Ÿ” One-Time Auth - Connect Twitter once, works forever (auto token refresh)
  • ๐Ÿค– Smart Extraction - AI knows what's the tweet vs side comments
  • ๐Ÿ”• Silent Collection - Only notifies when tweet is posted
  • ๐Ÿ“ฑ Works 24/7 - Deployed on Railway with persistent storage

๐Ÿš€ Quick Start

For OMI Users

  1. Install the app in your OMI mobile app
  2. Authenticate your Twitter account (one-time)
  3. Start tweeting!
    • Say: "Tweet Now, I love using OMI to tweet with my voice!"
    • The app collects your speech (up to 3 segments)
    • AI extracts and posts the tweet
    • You get a notification when it's posted! โœ…

Trigger Phrases

  • "Tweet Now"
  • "Post Tweet"
  • "Send Tweet"
  • "Tweet This"

How It Works

The app is smart about collecting your speech:

  1. Detects "Tweet Now" โ†’ Starts collecting
  2. Automatically collects the next 2 segments (or waits for them)
  3. Sends all 3 segments to AI
  4. AI extracts the actual tweet, removes filler words
  5. Posts to Twitter!
  6. Notifies you once โœ…

Example:

You: "Tweet Now, I just had"
     [collecting silently...]
You: "an incredible idea about"
     [collecting silently...]
You: "voice AI and social media!"
     โ†’ AI processes all 3 segments
     โ†’ Posts: "I just had an incredible idea about voice AI and social media!"
     โ†’ Notification sent! ๐Ÿ””

๐ŸŽฏ OMI App Configuration

FieldValue
Webhook URLhttps://omi-twitter.up.railway.app/webhook
App Home URLhttps://omi-twitter.up.railway.app/
Auth URLhttps://omi-twitter.up.railway.app/auth
Setup Completed URLhttps://omi-twitter.up.railway.app/setup-completed

๐Ÿ› ๏ธ Development Setup

Prerequisites

  • Python 3.10+
  • Twitter Developer Account with API v2 access
  • OpenAI API key
  • OMI device and app

Installation

bash
# Clone the repository
git clone https://github.com/aaravgarg/omi-twitter-app.git
cd omi-twitter-app

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your API keys

Configuration

Create .env file with:

env
# Twitter API Credentials (from developer.twitter.com)
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_CLIENT_ID=your_client_id
TWITTER_CLIENT_SECRET=your_client_secret

# OAuth Redirect URL
OAUTH_REDIRECT_URL=http://localhost:8000/auth/callback

# OpenAI API Key (for AI tweet extraction)
OPENAI_API_KEY=your_openai_key

# App Settings
APP_HOST=0.0.0.0
APP_PORT=8000

Twitter Developer Setup

  1. Go to Twitter Developer Portal
  2. Create a new app or use existing
  3. Enable OAuth 2.0
  4. Set permissions to Read and Write
  5. Add callback URL: http://localhost:8000/auth/callback (for local dev)
  6. Note your API credentials

Run Locally

bash
source venv/bin/activate
python main_simple.py

Visit http://localhost:8000/test to test!

โ˜๏ธ Railway Deployment

Quick Deploy

  1. Push to GitHub

    bash
    git push origin main
    
  2. Deploy on Railway

    • Go to railway.app
    • New Project โ†’ Deploy from GitHub
    • Select your repo
    • Add environment variables (from your .env)
  3. Get your URL

    • Settings โ†’ Networking โ†’ Generate Domain
    • You'll get: your-app.up.railway.app
  4. Update OAuth Redirect

    • Railway Variables: OAUTH_REDIRECT_URL=https://your-app.up.railway.app/auth/callback
    • Twitter Portal: Add same callback URL
  5. Configure OMI

    • Use your Railway URLs in OMI app settings

Railway Environment Variables

Add these in Railway dashboard:

TWITTER_API_KEY
TWITTER_API_SECRET
TWITTER_CLIENT_ID
TWITTER_CLIENT_SECRET
OPENAI_API_KEY
OAUTH_REDIRECT_URL=https://your-app.up.railway.app/auth/callback
APP_HOST=0.0.0.0
APP_PORT=8000

๐Ÿงช Testing

Web Interface

Visit https://omi-twitter.up.railway.app/test to:

  • Authenticate your Twitter account
  • Test voice commands by typing
  • See real-time logs
  • Verify tweets are posting

With OMI Device

  1. Configure webhook URLs in OMI Developer Settings
  2. Enable the integration
  3. Authenticate Twitter
  4. Say: "Tweet Now, This is a test!"
  5. Wait for collection (silent)
  6. Get notification when posted! ๐ŸŽ‰

๐Ÿง  AI Processing

The app uses OpenAI for two things:

  1. Tweet Extraction - Analyzes all 3 segments to extract what's actually the tweet
  2. Cleanup - Removes filler words, fixes grammar, capitalizes properly

Example:

Input (3 segments):
"that this is amazing and um I think"
"it's really cool and oh wait"
"I need to remember to buy milk later"

AI Output:
"That this is amazing and I think it's really cool"
(Milk reminder correctly excluded!)

๐Ÿ“Š How Segments Work

OMI sends transcripts in segments as you speak. The app:

  • โœ… Detects "Tweet Now" trigger
  • โœ… Collects exactly 3 segments
  • โœ… Silent during collection (no spam)
  • โœ… AI processes all 3 together
  • โœ… One notification on completion

Why 3 segments?

  • Gives you time to complete your thought
  • Captures ~10-20 seconds of speech
  • AI has full context for extraction
  • Balances speed vs completeness

๐Ÿ” Security & Privacy

  • โœ… Tokens stored securely with file persistence
  • โœ… Auto token refresh (never expires)
  • โœ… OAuth 2.0 authentication
  • โœ… Environment variables for secrets
  • โœ… Per-user token isolation
  • โœ… HTTPS enforced in production

๐Ÿ› Troubleshooting

"User not authenticated"

  • Complete Twitter OAuth flow
  • Check Railway logs for auth errors
  • Re-authenticate if needed

"Tweet not posting"

  • Check Railway logs for errors
  • Verify Twitter app has "Read and Write" permissions
  • Ensure you said "Tweet Now" trigger phrase
  • Wait for all 3 segments to be collected

"Session resets between segments"

  • This should be fixed! Session uses consistent ID per user
  • Check Railway logs - should see same session_id
  • Contact support if issue persists

"Railway deployment fails"

  • Verify all environment variables are set
  • Check build logs for specific errors
  • Ensure OAUTH_REDIRECT_URL is set correctly

๐Ÿ“ Project Structure

omi-twitter-app/
โ”œโ”€โ”€ main_simple.py           # FastAPI application
โ”œโ”€โ”€ twitter_client.py        # Twitter API integration
โ”œโ”€โ”€ tweet_detector.py        # AI-powered tweet detection & extraction
โ”œโ”€โ”€ simple_storage.py        # File-based storage (users & sessions)
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ railway.toml            # Railway deployment config
โ”œโ”€โ”€ runtime.txt             # Python version
โ”œโ”€โ”€ Procfile                # Alternative deployment platforms
โ”œโ”€โ”€ .env.example            # Environment template
โ”œโ”€โ”€ .gitignore             # Git ignore rules
โ”œโ”€โ”€ LICENSE                # MIT License
โ””โ”€โ”€ README.md              # This file

๐Ÿ”ง API Endpoints

EndpointMethodDescription
/GETSetup instructions & info
/authGETStart Twitter OAuth flow
/auth/callbackGETOAuth callback handler
/setup-completedGETCheck if user authenticated
/webhookPOSTReal-time transcript processor
/testGETWeb testing interface
/healthGETHealth check

๐Ÿค Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open a Pull Request

๐Ÿ“ License

MIT License - see LICENSE file for details.

๐Ÿ†˜ Support

๐ŸŽ‰ Credits

Built for the OMI ecosystem.

  • OMI Team - Amazing wearable AI platform
  • Twitter API - Social media integration
  • OpenAI - Intelligent text processing

Made with โค๏ธ for voice-first social media

Deployed at: omi-twitter.up.railway.app