Control Spotify Playback via Telegram and AI with n8n

Discover how this n8n automation lets you control Spotify music using Telegram messages enhanced by AI to identify songs. It turns chat commands into Spotify actions like playing, skipping, and reporting current tracks, saving time and enhancing music interaction effortlessly.
telegramTrigger
openAi
spotify
+5
Workflow Identifier: 1756
NODES in Use: Telegram Trigger, OpenAI, Spotify, Sticky Note, Merge, If, Set, Telegram
Control Spotify with n8n and Telegram

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow lets you control Spotify using Telegram messages. It solves the problem of switching apps and typing song names wrong. When you send a message in Telegram, it finds the song on Spotify, adds it to your queue, skips to it, and plays it. Then it tells you which song is playing back in Telegram.

The workflow uses AI to understand what song you want, even if you type it badly or describe it roughly. This saves time and stops you from breaking your chat flow to search manually.


Tools and Services Used

  • Telegram Bot API: Receives user messages.
  • OpenAI (GPT-4o-mini): Extracts artist and track names from messages.
  • Spotify API: Searches tracks, controls playback (requires Premium).
  • n8n Automation Platform: Runs and connects all nodes.

Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Import Workflow

  1. Download the workflow file using the Download button on this page.
  2. Inside the n8n editor, click “Import from File” and upload the downloaded workflow.

Step 2: Configure Credentials

  1. Add your Telegram Bot API credentials in the Telegram Trigger node.
  2. Add your OpenAI API Key in the OpenAI node.
  3. Add your Spotify OAuth credentials in all Spotify nodes.
  4. Check and update any IDs, emails, or channel names if present.

Step 3: Test and Activate

  1. Run the workflow once by sending a message to your Telegram bot.
  2. Check if the song correctly adds to Spotify and reply sends back.
  3. Activate the workflow by turning it on in n8n for production use.

Consider using self-host n8n to run the workflow securely and reliably.


Workflow Inputs, Processing, and Outputs

Inputs

  • User sends a text message to Telegram Bot.

Processing Steps

  • OpenAI reads the message and extracts artist and track details.
  • Spotify nodes search for the track using extracted data.
  • If track found, it is added to the queue, then playback is skipped to it.
  • If paused, playback resumes.
  • Spotify fetches currently playing song details.
  • Formatted now playing message is prepared.

Outputs

  • Telegram bot replies with current song info.
  • If no track found, bot replies with “Song not found” message.

Common Problems and Troubleshooting

  • Song not found error:
    OpenAI might not extract correct names or Spotify search query can fail.
    Check prompt setup and query input.
  • Spotify resume errors:
    Resuming when already playing can cause errors.
    This is safe to ignore as the workflow continues.
  • Telegram Trigger not firing:
    Usually caused by missing or invalid Bot API credentials.
    Verify Bot setup and credentials inside n8n.

Customization Ideas

  • Switch OpenAI model in the node to improve accuracy.
  • Add nodes to control pause, previous track, or shuffle functions.
  • Update Telegram Trigger to handle multiple users or groups.
  • Adjust AI prompt for better understanding or different languages.

Code Example: OpenAI Prompt Template

Use this prompt to extract artist and track names clearly:

=get artist and song name from '{{ $json.message.text }}'. Reply only eg. 'track:song name artist:artist name'

This prompt helps OpenAI respond with structured info for Spotify search.


Summary

✓ Sends Telegram messages as song requests to Spotify.

✓ Uses AI to interpret vague or partial song details.

✓ Automatically adds songs to playback and resumes music.

→ Keeps chat and music flow together without app switching.

→ Saves users time searching and typing song information.


Control Spotify with n8n and Telegram

Visit through Desktop to Interact with the Workflow.

Author
Written By
Vikash Kumar
Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.
Author
Written By
Vikash Kumar
Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.

Frequently Asked Questions

No, Spotify API playback controls need a Premium account.
OpenAI node reads the Telegram message and extracts artist and track names for Spotify search.
Check that Telegram Bot API credentials are correct and the bot is active.
Yes, all tokens and API keys are stored securely in n8n and data stays within user accounts.

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.