Output will stream here when you run the agent.
Summary
The Chat with YouTube Agent answers questions about a video using its transcript. It pulls the video's metadata and full transcript, then summarizes, answers follow-ups, and generates chapter timestamps — each citation a clickable link straight to that moment. Reach for it to skim long talks, lectures, or podcasts without watching end to end.
Installation
$ pnpm dlx shadcn@latest add @agentcn/mastra/chat-with-youtube
Composition
├── config.ts # Agent definition (model + config)
├── instructions.md # Comprehensive YouTube assistant instructions
├── memory.ts # Memory instance
├── lib/
│ └── youtube-utils.ts # Video ID extraction + timestamp formatting
└── tools/
├── youtube-metadata.ts # Fetch video title, author, description, duration
└── youtube-transcript.ts # Fetch timestamped transcript segmentsHow It Works
- Get Metadata -
fetch-youtube-metadataretrieves video title, author, description, and duration - Get Transcript -
fetch-youtube-transcriptfetches the full transcript with timestamps - Answer Questions - The agent answers based on transcript content with clickable timestamp citations
- Generate Chapters - Creates chapter timestamps in YouTube description format
Customization
- Swap the model. Edit the
modelfield inconfig.ts. - Add chapters export. Add a tool that writes the chapter list back as a YouTube description or VTT file.
- Handle missing transcripts. Fall back to an STT service when a video has no captions.
- Swap metadata source. Use the YouTube Data API for richer metadata.