An automated system that monitors YouTube channels for new videos, analyzes their transcripts for specific keywords, and automatically places bets on Kalshi prediction markets based on word mentions.
- Real-time Video Monitoring - Automatically polls YouTube channels for new video uploads
- Transcript Analysis - Fetches and analyzes video transcripts to check for keyword mentions
- Automated Betting - Places YES/NO bets on Kalshi markets based on transcript analysis
- Manual Analysis - Web UI for analyzing individual videos on-demand
- Risk Management - Configurable bet amounts (defaults to 1% daily risk limit)
- Dual Deployment - Supports local polling or Vercel cron-based execution
- Framework: Next.js 16 (App Router) with React 19
- Language: TypeScript
- Runtime: Bun
- UI: Tailwind CSS, Radix UI, Shadcn/UI
- APIs: YouTube RSS Feeds, Kalshi Trading API
- Storage: Upstash Redis (for tracking processed videos)
- Deployment: Vercel with cron jobs
- Bun installed
- Kalshi API credentials (API key + private key)
- Upstash Redis instance (free tier available)
- YouTube channel URL to monitor
Create a .env.local file in the project root:
# Kalshi API Credentials
KALSHI_API_KEY=your_kalshi_api_key
KALSHI_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour\nPrivate\nKey\nHere\n-----END PRIVATE KEY-----"
# Trading Configuration
BET_AMOUNT=10 # Number of contracts per bet
MARKET_ID_YES=your_market_ticker # Kalshi market ticker for YES bets
MARKET_ID_NO=your_market_ticker # Kalshi market ticker for NO bets
# YouTube Configuration
YOUTUBE_CHANNEL_URL=https://youtube.com/@channelname
WORDS_TO_CHECK=word1,word2,word3 # Comma-separated words to check
# Redis (Upstash)
UPSTASH_REDIS_REST_URL=https://your-redis-url.upstash.io
UPSTASH_REDIS_REST_TOKEN=your_redis_token# Clone the repository
git clone <your-repo-url>
cd bet
# Install dependencies
bun install# Start the development server
bun dev- Opens at
http://localhost:3000 - Automatic polling starts after 5 seconds
- Polls every 5 minutes for new videos
- View manual analysis UI in the browser
# Deploy to Vercel
vercel deploy --prodOn Vercel:
- Automatic polling is disabled bec we use cron jobs
- Cron job runs every 5 minutes via
/api/poll - Configure environment variables in Vercel dashboard
- Cron schedule defined in
vercel.json
- Fetches YouTube channel RSS feed every 5 minutes
- Extracts latest video ID and metadata
- Compares with last processed video stored in Redis
- Downloads video transcript using YouTube's API
- Searches for configured keywords (case-insensitive, whole word matching)
- Returns list of mentioned and not mentioned words
- Words Mentioned: Places YES bets on configured market
- Words Not Mentioned: Places NO bets on configured market
- Uses limit orders (99 cents for YES, 1 cent for NO)
- Each bet uses configured contract amount (default: 10 contracts)
- Stores last processed video ID in Redis
- Prevents duplicate processing of the same video
- Maintains betting history and results
├── app/
│ ├── api/
│ │ ├── analyze-video/ # Manual video analysis endpoint
│ │ ├── get-latest-video/ # Fetch latest video from channel
│ │ ├── place-bet/ # Place individual bet
│ │ └── poll/ # Polling endpoint (cron trigger)
│ ├── globals.css
│ ├── layout.tsx
│ └── page.tsx # Main UI
├── lib/
│ ├── analyze-video-logic.ts # Video transcript analysis
│ ├── kalshi.ts # Kalshi API client
│ ├── place-bet-logic.ts # Betting logic
│ ├── poll-logic.ts # Polling cycle logic
│ ├── polling-service.ts # Local polling service
│ ├── redis.ts # Redis client
│ ├── youtube.ts # YouTube API utilities
│ └── utils.ts # Shared utilities
├── components/
│ └── ui/ # Shadcn UI components
├── vercel.json # Vercel cron configuration
└── package.json
Manually analyze a video for keyword mentions.
{
"videoId": "dQw4w9WgXcQ",
"words": ["word1", "word2"]
}Trigger a polling cycle (checks for new video and processes it).
Manually place a bet on Kalshi.
{
"word": "keyword",
"action": "yes",
"marketId": "TICKER-123"
}Fetch the latest video from a YouTube channel.