Animated data flow diagram

AI Telegram Spotify DJ using n8n, OpenAI, and Spotify

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

Telegram OpenAI Spotify

Overview

Unlock Effortless Spotify Control with this AI Agent

This AI Agent transforms your Telegram chat into a powerful remote for Spotify. Simply send a message with the song you want to hear – whether it's a direct title and artist, or a more casual description – and the agent gets to work. It uses OpenAI's GPT-4o-mini model to intelligently interpret your request, extracts the track and artist information, then seamlessly interacts with Spotify to find the song, add it to your playback queue, skip to it, and start playing. You'll receive confirmation or updates right back in your Telegram chat, making music control a breeze.

Key Features & Benefits

  • AI-Powered Song Recognition: Leverages OpenAI (GPT-4o-mini) to understand natural language music requests sent via Telegram. Accurately extracts artist and track details even from informal messages.
  • Seamless Spotify Integration: Automates searching for tracks, adding them to the queue, initiating playback (resume), skipping to the newly added song, and fetching current playback status on your Spotify account.
  • Interactive Telegram Bot: Provides real-time feedback in Telegram, confirming the song now playing or notifying if a track couldn't be found.
  • Error Handling: Includes logic to manage scenarios where songs aren't found or other Spotify playback issues occur, informing the user gracefully.
  • No-Code Customization: Built with n8n, allowing easy modification and extension of commands or integration with other services without writing code.
  • Remote Music Management: Control your Spotify from anywhere you have Telegram access, perfect for managing music without interrupting your workflow or needing the Spotify app open.

Use Cases

  • Solopreneurs: Quickly play focus music or your favorite tracks while working, without switching apps, maintaining flow state.
  • Founders/CTOs: Demonstrate innovative AI integrations for internal team morale (e.g., office DJ bot) or as a fun, practical example of automation capabilities.
  • Heads of Automation: Explore a hands-on example of integrating LLMs for natural language interaction with APIs, applicable to various chatbot or command-driven automations.
  • Personal Productivity: Effortlessly control your music queue using voice-to-text on Telegram or quick messages, minimizing context switching.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • OpenAI API Key with access to a suitable model (e.g., gpt-4o-mini).
  • Spotify Developer App credentials (Client ID & Client Secret) and OAuth2 credentials configured in n8n.
  • Telegram Bot Token for configuring the Telegram Trigger node in n8n.

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Configure the 'Telegram Trigger' node: create new credentials using your Telegram Bot Token. The workflow will listen for messages sent to this bot.
  4. Configure the 'OpenAI - Ask about a track' node: create new credentials using your OpenAI API Key. Ensure the selected model (e.g., gpt-4o-mini) is available to your key.
  5. Configure all 'Spotify' nodes ('Search track', 'Add song', 'Next Song', 'Resume play', 'Currently Playing'): create and select your Spotify OAuth2 credentials in n8n. You'll need a Spotify Developer App Client ID and Client Secret for this.
  6. The OpenAI node is prompted to extract track and artist. The Spotify 'Search track' node uses this output for its query.
  7. Test by sending a message to your Telegram bot (e.g., "Play 'Bohemian Rhapsody by Queen'" or "Play that popular song by Dua Lipa from the Barbie movie").
  8. The 'Return message to Telegram' node automatically uses the Chat ID from the trigger for replies.
  9. Activate the workflow.

Tags:

AI AgentSpotifyTelegramOpenAIMusic AutomationProductivityNLPChatbotAutomation

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation