A sentiment-inclined agent that analyzes your mood and recommends music from Spotify.
- Go to Spotify Developer Dashboard
- Log in or create a Spotify account
- Create a new application to get your
Client IDandClient Secret - Accept the terms and create the app
-
Copy
.env.exampleto.env:cp .env.example .env
-
Add your Spotify credentials:
SPOTIFY_CLIENT_ID=your_client_id_here SPOTIFY_CLIENT_SECRET=your_client_secret_here -
(Optional) Add Teneo Agent SDK credentials if using NFT features:
PRIVATE_KEY=your_private_key_here NFT_TOKEN_ID=your_nft_token_id_here OWNER_ADDRESS=your_owner_address_here
go mod download
go mod tidygo run main.goThe agent supports the mood_analyzer command:
mood_analyzer [mood description]
mood_analyzer I feel happy and energetic
mood_analyzer I'm feeling sad and lonely
mood_analyzer I want to relax and chill
mood_analyzer I'm focused and working
mood_analyzer I'm in a romantic mood
- Mood Detection: The agent analyzes your mood description and identifies the primary mood
- Profile Generation: Based on the detected mood, it creates a music profile with Spotify audio features:
- Energy level
- Danceability
- Valence (musical positiveness)
- Acousticness
- Music Search: Uses the Spotify API to search for tracks matching your mood
- Recommendations: Returns the top 5 recommended tracks with links to play them on Spotify
- Happy: Upbeat, joyful, excited music
- Sad: Emotional, melancholic, soulful tracks
- Relaxed: Calm, peaceful, ambient music
- Energetic: High-energy, powerful, intense tracks
- Romantic: Love songs, passionate music
- Focused: Concentration-friendly music
mood_analyst/
├── main.go # Main application and agent handler
├── go.mod # Go module file
├── .env.example # Example environment variables
├── spotify/
│ └── client.go # Spotify API client
└── mood/
└── analyzer.go # Mood analysis and music recommendations
- 🎵 Spotify API integration for real music recommendations
- 🧠 Mood detection from natural language descriptions
- 🎯 Smart audio feature matching (energy, danceability, valence, etc.)
- 🔗 Direct Spotify links for each recommendation
- 📱 Works with Teneo Agent SDK for multi-agent orchestration
NewClient(): Initialize the Spotify API clientAuthenticate(): Get access token using Client Credentials FlowSearchTracks(): Search for songs based on queryGetRecommendations(): Get recommendations based on seed tracks and mood parametersLoadFromEnv(): Load credentials from environment variables
AnalyzeMood(): Analyze mood description and return mood profileGetMoodParameters(): Generate Spotify audio feature targetsFormatTrackRecommendation(): Format track data for display
The agent gracefully handles:
- Missing Spotify credentials
- Authentication failures
- API rate limits
- No results found scenarios
- Never commit
.envwith real credentials - Use the provided
.env.exampleas a template - Keep your Spotify credentials secure
- The Client Credentials Flow is used (server-to-server, no user login required)
- Playlist creation from recommendations
- User preference learning
- Mood history tracking
- Multi-language support
- Real-time mood tracking with wearables
- Go 1.25+
- github.com/TeneoProtocolAI/teneo-agent-sdk
- github.com/joho/godotenv (for .env file loading)
- Standard library HTTP and JSON packages
See LICENSE file in the teneo-agent-sdk for licensing information.