You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

replyt

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replyt

Automate YouTube comment replies using AI - A TypeScript library and CLI tool for intelligent YouTube comment management with OpenAI GPT integration

1.0.4
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Replyt

npm version License: MIT

Replyt is a TypeScript npm package that allows you to automate YouTube comment replies using AI. Built with OpenAI GPT and YouTube Data API v3.

🚀 Features

  • Full Automation: Automatically reply to YouTube comments
  • 🤖 Smart AI: Uses OpenAI GPT to generate natural responses
  • 🌍 Multi-language: Replies in the same language as the comment
  • 📊 Database Tracking: Tracks processed comments
  • Rate Limiting: Respects YouTube API limits
  • 🔧 Configurable: Customize reply style, intervals, and more
  • 📦 CLI & Library: Use as command line tool or import as library

📦 Installation & Setup

📋 Requirements

System Requirements:

  • Node.js 16.0.0 or higher
  • npm (comes with Node.js)

API Requirements:

  • YouTube Data API v3 key
  • YouTube Channel ID
  • OpenAI API key
  • YouTube OAuth credentials for posting

🔑 Getting Required Credentials

Before running the setup, you'll need to obtain several API credentials. Here's how to get each one:

1. YouTube Data API Key

  • Go to Google Cloud Console
  • Create a new project or select an existing project
  • Go to "APIs & Services""Library"
  • Search for "YouTube Data API v3" and click "ENABLE"
  • Go to "APIs & Services""Credentials"
  • Click "+ CREATE CREDENTIALS""API key"
  • Copy the API key
  • (Recommended) Restrict the key to "YouTube Data API v3" for security

2. YouTube Channel ID

Option A: From Channel URL

  • If your URL is youtube.com/channel/UCxxxxxx, the part after /channel/ is your Channel ID

Option B: From Custom URL

  • If your URL is youtube.com/@username or youtube.com/c/username:
    • Go to your YouTube channel
    • Click "About" tab
    • Click "Share Channel"
    • Copy the Channel ID (format: UCxxxxxxxxxxxxxxxxxxxxxx)

3. OpenAI API Key

  • Go to OpenAI Platform
  • Sign up or log in to your account
  • Go to "API keys" section
  • Click "Create new secret key"
  • Copy the API key (starts with sk-proj- or sk-)

4. YouTube OAuth Credentials

Step 1: OAuth Consent Screen

  • Go to Google Cloud Console
  • Make sure you're in the same project as your YouTube Data API
  • Go to "APIs & Services""OAuth consent screen"
  • Choose "External" user type, click "CREATE"
  • Fill required fields:
    • App name: Replyt (or any name)
    • User support email: your email
    • Developer contact: same email
  • IMPORTANT: In "Test users" section → "ADD USERS" → enter your email

Step 2: Create OAuth Client

  • Go to "APIs & Services""Credentials"
  • Click "+ CREATE CREDENTIALS""OAuth client ID"
  • Application type: "Desktop application"
  • Name: Replyt YouTube Bot
  • Click "CREATE"
  • Copy the Client ID and Client secret

Troubleshooting OAuth Setup:

  • If you get "Access blocked" error, make sure your email is added as Test User
  • OAuth consent screen status should be "Testing" (not "In production")
  • Wait 5-10 minutes after adding test user before trying again

Choose Your Installation Method

There are two main ways to use Replyt:

Best for: Quick setup, production use, non-developers

# 1. Install globally
npm install -g replyt

# 2. Create and navigate to your bot directory
mkdir replyt-bot
cd replyt-bot

# 3. Setup configuration
replyt setup

# 4. Start the bot
replyt

CLI Commands:

  • replyt - Start the bot
  • replyt setup - Complete setup wizard (API + OAuth)
  • replyt test - Test API connections
  • replyt --help - Show help
  • replyt --version - Show version

🛠️ Method 2: Local Development (For Developers)

Best for: Developers, customization, contributing, learning

# 1. Clone repository
git clone https://github.com/rfqma/replyt.git
cd replyt

# 2. Install dependencies
npm install

# 3. Setup configuration
npm run setup

# 4. Start in development mode
npm run dev

Development Commands:

  • npm run dev - Development mode with auto-restart
  • npm run start - Production mode (requires build)
  • npm run build - Compile TypeScript
  • npm run watch - Development with file watching
  • npm run setup - Complete setup wizard (API + OAuth)
  • npm run test - Test configuration
  • npm run clean - Clean build files

🚀 Quick Comparison

FeatureCLI InstallLocal Development
Setup Time⚡ Fast (2 minutes)🔧 Medium (5 minutes)
Customization❌ Limited✅ Full access
Updatesnpm update -g replyt🔄 git pull
Debugging❌ Limited✅ Full debugging
Contributing❌ No✅ Yes
Storage⚡ Minimal💾 Full source code

🔧 Configuration

Both methods require a .env file with your API credentials:

# Required
YOUTUBE_API_KEY=your_youtube_api_key_here
YOUTUBE_CHANNEL_ID=your_channel_id_here
OPENAI_API_KEY=your_openai_api_key_here

# Required (for posting comments)
YOUTUBE_CLIENT_ID=your_client_id_here
YOUTUBE_CLIENT_SECRET=your_client_secret_here
YOUTUBE_REFRESH_TOKEN=your_refresh_token_here
YOUTUBE_ACCESS_TOKEN=your_access_token_here

# Bot Settings (optional)
CHECK_INTERVAL_MINUTES=5
MAX_REPLIES_PER_RUN=10
REPLY_STYLE="friendly and helpful"
DATABASE_PATH=./data/replyt.db

🎯 Usage Instructions

🌐 CLI Usage (Global Install)

After global installation and setup:

# Navigate to your bot directory
cd replyt-bot

# Start the bot
replyt

# That's it! The bot will run automatically

💻 Local Development Usage

Running the Bot:

npm run dev     # Development mode with auto-restart
npm run start   # Production mode (requires build)
npm run watch   # Development with file watching

Development Commands:

npm run build   # Compile TypeScript
npm run clean   # Clean build files
npm run test    # Test API connections
npm run setup   # Run setup wizard

📚 Library Usage (Both Methods)

You can also use Replyt as a library in your own projects:

# Install as dependency
npm install replyt
import { Replyt, AutoReplyBot, config } from "replyt";

// Using the Replyt wrapper class
const bot = new Replyt(config);

// Start bot with cron scheduling
await bot.start("*/5 * * * *"); // Every 5 minutes

// Or use manually
await bot.initialize();
await bot.processNewComments();
const stats = await bot.getStats();

Advanced Usage with AutoReplyBot

import { AutoReplyBot, config, validateConfig } from "replyt";

// Validate configuration
validateConfig();

// Create bot instance
const bot = new AutoReplyBot(config);

// Initialize
await bot.initialize();

// Process comments once
await bot.processNewComments();

// View statistics
const stats = await bot.getStats();
console.log(stats);

// Shutdown
bot.shutdown();

📋 API Documentation

Classes

Replyt

Wrapper class for easy library usage.

class Replyt {
  constructor(config: Config);
  async initialize(): Promise<void>;
  async processNewComments(): Promise<void>;
  async getStats(): Promise<object>;
  async start(cronExpression?: string): Promise<void>;
  shutdown(): void;
}

AutoReplyBot

Core bot class with full control.

class AutoReplyBot {
  constructor(config: Config);
  async initialize(): Promise<void>;
  async processNewComments(): Promise<void>;
  async getStats(): Promise<object>;
  shutdown(): void;
}

Services

YouTubeService

  • Fetch comments from channel
  • Post replies to YouTube
  • OAuth management

OpenAIService

  • Generate AI responses
  • Filter comments that need replies
  • Multi-language support

DatabaseService

  • SQLite database for tracking
  • Store comment status
  • Processing statistics

Types

interface Config {
  youtubeApiKey: string;
  youtubeChannelId: string;
  youtubeOAuth: OAuthCredentials;
  openaiApiKey: string;
  checkIntervalMinutes: number;
  maxRepliesPerRun: number;
  replyStyle: string;
  databasePath: string;
}

interface YouTubeComment {
  id: string;
  videoId: string;
  authorDisplayName: string;
  textDisplay: string;
  publishedAt: string;
  // ... other properties
}

⚙️ Configuration

Environment Variables

VariableRequiredDefaultDescription
YOUTUBE_API_KEY-YouTube Data API v3 key
YOUTUBE_CHANNEL_ID-Your YouTube channel ID
OPENAI_API_KEY-OpenAI API key
YOUTUBE_CLIENT_ID-OAuth client ID (for posting)
YOUTUBE_CLIENT_SECRET-OAuth client secret
YOUTUBE_REFRESH_TOKEN-OAuth refresh token
CHECK_INTERVAL_MINUTES5Comment check interval (minutes)
MAX_REPLIES_PER_RUN10Max replies per cycle
REPLY_STYLE"friendly and helpful"AI reply style
DATABASE_PATH"./data/replyt.db"SQLite database path

Reply Styles

You can customize AI reply style by changing REPLY_STYLE:

  • "friendly and helpful"
  • "professional and formal"
  • "casual and funny"
  • "educational and informative"
  • Custom: "Always reply in Indonesian with emojis"

🔐 OAuth Setup Required

OAuth authentication is required for the bot to post replies to YouTube. The setup process will guide you through:

  • Creating YouTube OAuth credentials
  • Authorizing the application
  • Generating access and refresh tokens

Setup Commands:

CLI: replyt setup Local: npm run setup

📊 Monitoring

The bot provides detailed logging and statistics:

🤖 Bot initialized successfully
📝 Found 25 total comments
🆕 Found 5 new comments to process
🧠 Generating reply for comment by John Doe...
📤 Posting reply: "Thank you for watching! ..."
✅ Successfully replied to comment abc123
📊 Total comments processed: 150

🛠️ Development (Local Repository)

Quick Start

git clone https://github.com/rfqma/replyt.git
cd replyt
npm install
npm run setup
npm run dev

Available Scripts

CommandDescription
npm run devDevelopment mode with auto-restart
npm run startProduction mode (requires build)
npm run buildCompile TypeScript
npm run watchDevelopment with file watching
npm run setupComplete setup wizard (API + OAuth)
npm run testTest configuration
npm run cleanClean build files
npm run validateValidate package structure

Project Structure

replyt/
├── src/
│   ├── bin/replyt.ts      # CLI executable
│   ├── lib/index.ts       # Library exports
│   ├── services/          # Core services
│   ├── config/            # Configuration
│   └── types/             # TypeScript types
├── scripts/               # Setup scripts
├── examples/              # Usage examples
└── dist/                  # Compiled output

🔧 Troubleshooting

Common Issues

  • API Key Invalid

    Error: The request cannot be completed because you have exceeded your quota.
    
    • Check YouTube API key and quota
    • Ensure YouTube Data API v3 is enabled
  • OAuth Issues

    Error: invalid_grant
    
    • Refresh token expired, run setup again:
      • CLI: replyt setup
      • Local: npm run setup
  • OpenAI Rate Limits

    Error: Rate limit exceeded
    
    • Reduce MAX_REPLIES_PER_RUN
    • Increase CHECK_INTERVAL_MINUTES

Debug Mode

CLI: DEBUG=replyt:* replyt Local: DEBUG=replyt:* npm run dev

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please:

  • Fork the repository
  • Create a feature branch (git checkout -b feature/AmazingFeature)
  • Commit your changes (git commit -m 'Add some AmazingFeature')
  • Push to the branch (git push origin feature/AmazingFeature)
  • Open a Pull Request

📞 Support

🙏 Credits

Built with ❤️ using:

Keywords

youtube

FAQs

Package last updated on 26 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.