Generate Mood Based Spotify Playlist

Claude

Fetches your Spotify saved tracks, enriches them with audio features, and uses AI to generate a personalized playlist based on your current mood or preferences.

Spotify PlaylistAudio FeaturesMood AnalysisMusic Curation
Onur OruçOnur Oruç

This workflow connects to your Spotify account to fetch your saved tracks in batches, enriches each track with detailed audio features, and then uses AI to generate a personalized playlist based on your mood or preferences. It's perfect for music lovers and playlist curators who want to analyze their library and discover the right songs for any moment.

What It Does

  1. Starts with a mood prompt — A manual trigger accepts a description of your current mood, feeling, or setting.
  2. Fetches saved tracks in batches — Loops through your Spotify library, retrieving up to 800 saved tracks in batches of 40.
  3. Extracts track details — Parses each batch to pull out key metadata like name, artists, album, release date, popularity, and more.
  4. Retrieves audio features — Sends up to 100 track IDs per batch to the ReccoBeats API to get deeper audio insight (e.g., energy, tempo, danceability).
  5. Normalizes audio data — Ensures consistent formatting and length across all audio feature results.
  6. Merges track info and audio features — Combines all collected data into a unified dataset.
  7. Generates a mood-based playlist — An AI agent analyzes your mood description and curates a playlist of 25 tracks from your library that fit the vibe.

What You Need

  • A Spotify account with saved tracks
  • A valid Spotify API access token with the user-library-read scope
  • An access token for the ReccoBeats API (for audio features)
  • Needle platform access with the following connectors:
    • HTTP Request node
    • Code node
    • Loop node
    • Merge node
    • AI node

How the Flow Works

NodeDescription
Manual TriggerStarts the flow with a user-entered mood or comment describing your current emotion or environment.
LoopControls pagination to fetch up to 800 saved tracks across 20 batches (40 tracks per batch).
HTTP Request (Spotify Tracks)Calls the Spotify API to retrieve a batch of saved tracks using authorization headers.
Code (Extract Tracks)Parses the Spotify response to extract key track details (name, artists, album, release date, popularity) and collects track IDs.
Code (Build Audio Features Request)Prepares a request to the ReccoBeats audio features API using the collected track IDs.
HTTP Request (Audio Features)Fetches detailed audio features for the selected tracks from the ReccoBeats API.
Code (Normalize Features)Pads or formats the audio feature array to ensure consistent length and structure.
MergeCombines track metadata and audio features from the parallel branches.
AI Node (Playlist Generation)Analyzes your mood comment and generates a playlist of 25 tracks that match the described mood or theme.

Output

At the end of the flow, you receive a curated playlist of 25 tracks that match your described mood. The output includes structured data for each track:

  • Track name and artist names
  • Spotify URI and external URL
  • Album name and release date
  • Duration, popularity, and explicit flag

The result is returned as structured JSON, ready to be used or exported.

Notes

  • Make sure your Spotify access token has the correct scope (user-library-read) and is refreshed if expired.
  • Keep your ReccoBeats API token secure and ensure it remains valid.
  • The loop is limited to 20 batches to avoid excessive API calls — adjust this if your library is larger.
  • The AI playlist generation handles vague or ambiguous inputs by inferring the most likely musical style.
  • For production use, replace any hardcoded tokens in the nodes with dynamic variables or secure credential references.

Want to showcase your own workflows?

Become a Needle workflow partner and turn your expertise into recurring revenue.

Try Needle today

Streamline AI productivity at your company today

Join thousands of people who have transformed their workflows.

Agentic workflowsAutomations, meet AI agents
AI SearchAll your data, searchable
Chat widgetsDrop-in widget for your website
Developer APIMake your app talk to Needle
    Needle LogoNeedle
    Like many websites, we use cookies to enhance your experience, analyze site traffic and deliver personalized content while you are here. By clicking "Accept", you are giving us your consent to use cookies in this way. Read our more on our cookie policy .