⚡ Create playlists and control your Spotify player with GPT-4

4,038 views · ⚡ Personal Productivity

Description

This n8n template provides a powerful AI-powered chatbot that acts as your personal Spotify DJ. Simply tell the chatbot what kind of music you’re in the mood for, and it will intelligently create a custom playlist, give it a fitting name, and populate it with relevant tracks directly in your Spotify account.

The workflow is built to be flexible, allowing you to easily change the underlying AI model to your preferred provider, making it a versatile starting point for any AI-driven project.

Who is this for?

What problem does this solve?

Manually creating a good playlist is time-consuming. You have to think of a name, search for individual songs, and add them one by one. This workflow solves that by:

How it works

  1. Trigger & input: The workflow starts when you send a message in the Chat Trigger interface.
  2. AI agent & tool-use: An AI Agent, powered by a Large Language Model (LLM), interprets your message. It has access to a set of “tools” that allow it to interact with Spotify.
  3. Playlist creation sub-workflow: If you ask for a new playlist, the Agent calls a sub-workflow using the Create new playlist tool. This sub-workflow uses another AI call to brainstorm a creative playlist name and a list of suitable songs based on your request.
  4. Spotify actions: The sub-workflow then connects to Spotify to:
    • Create a new, empty playlist with the generated name.
    • Search for each song from the AI’s list to get its official Spotify Track ID.
    • Add each track to the new playlist.
  5. Player control: If your request is to control the music (e.g., “pause the music”), the Agent uses the appropriate tool (Pause player, Resume player, etc.) to directly control your active Spotify player.

Setup

  1. Accounts & API keys: You will need active accounts and credentials for:
    • Your AI provider (e.g., OpenAI, Groq, local LLMs via Ollama): To power the AI Agent and the playlist generation.
    • Spotify: To create playlists and control the player. You’ll need to register an application in the Spotify Developer Dashboard to get your credentials.
  2. Configure credentials:
    • Add your AI provider’s API key to the Chat Model nodes. The template uses OpenAI by default, but you can easily swap this out for any compatible Langchain model node.
    • Add your Spotify OAuth2 credentials to all Spotify and Spotify Tool nodes.
  3. Activate workflow: Once all credentials are set and the workflow is saved, click the “Active” toggle. You can now start interacting with your Spotify AI Agent via the chat panel!

Taking it further

This template is a great foundation. Here are a few ideas to expand its capabilities:

🔗 Nodes Used

Spotify, Execute Workflow Trigger, AI Agent, Basic LLM Chain, OpenAI Chat Model, Simple Memory

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup