Skip to main content

Create playlists and control your Spotify player with GPT-4

Workflow preview

Workflow preview
100%
Create playlists and control your Spotify player with GPT-4 preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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...

Best for

  • Personal Productivity automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.set, n8n-nodes-base.spotify, @n8n/n8n-nodes-langchain.chainllm, n8n-nodes-base.splitout, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.memorybufferwindow, n8n-nodes-base.executeworkflowtrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Guillaume Duvernay.

Original n8n.io source

1.1 Workflow description

Title
Create playlists and control your Spotify player with GPT-4
Workflow name
Create playlists and control your Spotify player with GPT-4

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?

  • Music lovers: Instantly create playlists for any activity, mood, or genre without interrupting your flow.
  • Developers & AI enthusiasts: A perfect starting point to understand how to build a functional AI Agent that uses tools to interact with external services.
  • Automation experts: See a practical example of how to chain AI actions and sub-workflows for more complex, stateful automations.

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:

  • Automating playlist creation: Turns a simple natural language request (e.g., "I need a playlist for my morning run") into a fully-formed Spotify playlist.
  • Reducing manual effort: Eliminates the tedious task of searching for and adding multiple tracks.
  • Providing player control: Allows you to manage your Spotify player (play, pause, next) directly from the chat interface.
  • Centralizing music management: Acts as a single point of control for both creating playlists and managing playback.

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:

  • Become the party DJ: Make the Chat Trigger's webhook public. You can then generate a QR code that links to the chat URL. Party guests can scan the code and request songs directly from their phones, which the agent can add to a collaborative playlist or the queue.
  • Expand the agent's skills: The Spotify Tool node has more actions available. Add a new tool for Add to Queue so you can ask the agent to queue up a specific song without creating a whole new playlist.
  • Integrate with other platforms: Swap the Chat Trigger for a Telegram or Discord trigger to build a Spotify bot for your community. You could also connect it to a Webhook to take requests from a custom web form.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - OpenAI Chat Model2

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 2 - Get track IDs

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 3 - Create playlist

Type / Role
n8n-nodes-base.spotify - spotify
Config choices
Version 1

Block 4 - Ideate playlist

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.6

Block 5 - Split out tracks

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 6 - Get tracks array

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 8 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 9 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 10 - When Executed by Another Workflow

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 11 - Add track to playlist

Type / Role
n8n-nodes-base.spotify - spotify
Config choices
Version 1

Block 12 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.2

Block 13 - Spotify Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.9

Block 14 - Get the final playlist

Type / Role
n8n-nodes-base.spotify - spotify
Config choices
Version 1

Block 15 - Clean data to share with agent

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - Play a playlist

Type / Role
n8n-nodes-base.spotifyTool - spotifyTool
Config choices
Version 1

Block 17 - Pause player

Type / Role
n8n-nodes-base.spotifyTool - spotifyTool
Config choices
Version 1

Block 18 - Resume player

Type / Role
n8n-nodes-base.spotifyTool - spotifyTool
Config choices
Version 1

Block 19 - Next song

Type / Role
n8n-nodes-base.spotifyTool - spotifyTool
Config choices
Version 1

Block 20 - Get user playlists

Type / Role
n8n-nodes-base.spotifyTool - spotifyTool
Config choices
Version 1

Block 21 - Create new playlist

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.2

Block 22 - Search the track

Type / Role
n8n-nodes-base.spotify - spotify
Config choices
Version 1

Block 23 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 29 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Create playlists and control your Spotify player with GPT-4
Complexity advanced
Nodes 29
Categories Personal Productivity, AI Chatbot
Author Guillaume Duvernay
Published 12 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/5923/5923.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Create playlists and control your Spotify player with GPT-4 do?

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...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Personal Productivity, AI Chatbot use case.