A Next.js application with Tambo AI integration for intelligent YouTube video discovery. Ask Tambo about any topic and it will search YouTube, rate videos by relevance, and display them in a beautiful grid with an embedded video player.
β¨ AI-Powered Video Search - Search YouTube for any topic using natural language
π― Smart Video Ranking - AI rates and filters videos for relevance
# Copy example env file
cp example.env.local .env.localThen add your API keys:
NEXT_PUBLIC_TAMBO_API_KEY=your_tambo_api_key
NEXT_PUBLIC_YOUTUBE_API_KEY=your_youtube_api_key # Optional - uses mock data if not providedGet your API keys:
- Tambo API Key: tambo.co/dashboard
- YouTube API Key: Google Cloud Console
npm installnpm run devOpen localhost:3000 in your browser.
| Route | Description |
|---|---|
/ |
Full chat interface with video search and player |
Try asking Tambo any of these:
"Show me React tutorials"
"Find videos about machine learning for beginners"
"I want to learn Python async programming"
"Best practices for system design interviews"
"Web development tips and tricks"
"How to pass Amazon software engineer interviews"
"TypeScript advanced patterns"
"Next.js full-stack development"
- Search - Ask Tambo to find videos about any topic
- Browse - View search results in a grid with video information
- Watch - Click any thumbnail to watch the video with full controls
- Refine - Ask Tambo to search again with different terms
- Discover - Get recommendations and explore new topics
- QUICK_START.md - Quick reference with example queries
- VIDEO_PLAYER_IMPLEMENTATION.md - YouTube video player implementation details
- ARCHITECTURE.md - Component hierarchy and data flow
- CLAUDE.md - Development guidelines for the Tambo template
src/
βββ app/
β βββ page.tsx # Home page
β βββ layout.tsx # Root layout with providers
β βββ globals.css # Global styles
β βββ chat/
β βββ page.tsx # Main chat interface
βββ components/
β βββ MyDashboard.tsx # Main dashboard container
β βββ TrendingTechVideos.tsx # Video grid and search
β βββ VideoCard.tsx # Individual video card
β βββ YouTubePlayer.tsx # Video player modal β NEW
β βββ ChatSidebar.tsx # Chat sidebar
β βββ Tab.tsx # Tab navigation
β βββ VideoGrid.tsx # Grid layout
β βββ VideoDescription.tsx # Video metadata
β βββ tambo/ # Tambo components
β β βββ message-thread-full.tsx
β β βββ message-input.tsx
β β βββ message.tsx
β β βββ graph.tsx
β β βββ ...
β βββ ui/
β βββ card-data.tsx
βββ lib/
β βββ tambo.ts # AI component & tool registration β UPDATED
β βββ system-prompt.ts # System prompt guide β NEW
β βββ thread-hooks.ts # Thread management
β βββ use-anonymous-user-key.ts
β βββ utils.ts
βββ services/
β βββ youtube-videos.ts # Video data service
β βββ youtube-api.ts # YouTube API integration
β βββ video-actions.ts # Video update callbacks
β βββ population-stats.ts # Demo data
βββ contexts/
βββ VideoContext.tsx # Video state management
The AI is configured to:
- Search immediately without asking follow-up questions
- Extract intent from user messages automatically
- Rate results using AI for relevance ranking
- Update UI in real-time as results arrive
Tools are registered in src/lib/tambo.ts:
export const tools: TamboTool[] = [
{
name: "searchVideos",
description: "PRIMARY TOOL FOR VIDEO SEARCH. ALWAYS use immediately...",
tool: searchAndUpdateVideos,
inputSchema: z.object({
query: z.string().describe("User's search intent"),
limit: z.number().optional().default(8),
sortBy: z.enum(["relevance", "date", "viewCount", "rating"]).optional(),
aiRating: z.boolean().optional().default(true),
}),
outputSchema: z.object({
success: z.boolean(),
message: z.string(),
query: z.string(),
videoCount: z.number(),
topVideos: z.array(z.object({...})),
}),
},
// Add more tools here
];Components are registered in src/lib/tambo.ts:
export const components: TamboComponent[] = [
{
name: "Graph",
description: "A component that renders various types of charts",
component: Graph,
propsSchema: graphSchema,
},
// Add more components here
];- File:
src/components/YouTubePlayer.tsx - Purpose: Display embedded YouTube videos in a modal
- Features:
- Full YouTube embed with native controls
- Autoplay enabled
- Video metadata display
- Dark theme design
- Close button and responsive layout
- File:
src/components/TrendingTechVideos.tsx - Purpose: Display video grid and handle search
- Features:
- Category filtering
- Real-time video updates
- Click to play functionality
- Loading states
- File:
src/components/MyDashboard.tsx - Purpose: Main container for dashboard and chat
- Features:
- Tab navigation (Discover/Dashboard)
- Video context management
- Chat sidebar integration
- Player state management
| Command | Description |
|---|---|
npm run dev |
Start development server (port 3000) |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint checks |
npm run lint:fix |
Run ESLint with auto-fix |
- Next.js 15 with App Router
- React 19
- TypeScript
- Tambo AI SDK (
@tambo-ai/react) - YouTube Data API v3
- Tailwind CSS v4
- Lucide React - Icons
- Recharts - Data visualization
- Zod - Schema validation
- Framer Motion - Animations
- Limit videos per search: Default is 8 videos (configurable)
- AI ranking enabled: Uses AI to filter low-relevance videos
- Caching: Video data is cached in component state
- Lazy loading: Videos load as they come into view
- Check that
NEXT_PUBLIC_YOUTUBE_API_KEYis set in.env.local - Verify the YouTube API is enabled in Google Cloud Console
- Check browser console for API errors
- Verify
NEXT_PUBLIC_TAMBO_API_KEYis set correctly - Check that Tambo API is accessible from your network
- Ensure the chat has loaded completely
- Check that video ID is valid (should be a YouTube video ID)
- Verify YouTube hasn't removed the video
- Clear browser cache and try again
- Try more specific search queries
- Check the AI rating threshold in
AIVideoSearch.ts - Disable AI rating if mock data is being used
- Tambo Documentation - Complete Tambo SDK docs
- YouTube API Docs - YouTube API reference
- Next.js Documentation - Next.js guide
- React Documentation - React reference
- Tailwind CSS - Styling guide
To contribute improvements:
- Create a feature branch
- Make your changes
- Update relevant documentation files
- Test thoroughly
- Submit a pull request
MIT - Feel free to use this project as a starting point for your own applications.
- Issues: Check existing documentation files
- Tambo Help: Tambo Discord
- YouTube API Issues: Google Cloud Support
Happy video searching! π₯β¨