Merge node
Telegram node
+4

Telegram to Spotify with OpenAI

Published 15 days ago

Categories

Template description

Search music and play to Spotify from Telegram

This workflow is a simple demonstration on accessing a message model from Telegram and it makes searching for songs an easy task even if you can't remember the artist or song name.
An OpenAI message model tries to figure out the song and sends it to an active Spotify device**.

Use case
Imagine an office where you play music in the background and the employees can control the music without having to login to the playing account.

How it works

  • You describe the song in Telegram.
  • Telegram bot sends the text to n8n.
  • An OpenAI message model tries to find the song.
  • Spotify gets the search query string.
  • First match is then added to queue.
    -- If there is no match a message is sent to Telegram and the process ends.
  • We change to the next track in the list.
  • We make sure the song starts playing by trying to resume.
  • We fetch the currently playing track.
  • We return "now playing" information to Telegram: Song Name - Artist Name - Album Name.

Error handling

  • Every Spotify step has it's on error handler under settings where we output the error.
  • Message parser receives the error and sends it to Telegram.

Requirements

  • Active workflow*
  • OpenAI API key
  • Telegram bot
  • Spotify account and Oauth2 API
  • Spotify active on a device**

.* The Telegram trigger is activated only if this workflow is active. You can however TEST the workflow in the editor by clicking "Test step" and then it waits for the Telegram event. When event is received, just step through all steps or just clicking "Test step" on the "Fetch Now Playing" node.

.** You must have a Spotify device active when trying to communicate with a device. Open Spotify and play something - not it is active.

Share Template

More AI workflow templates

OpenAI Chat Model node
SerpApi (Google Search) node

AI agent chat

This workflow employs OpenAI's language models and SerpAPI to create a responsive, intelligent conversational agent. It comes equipped with manual chat triggers and memory buffer capabilities to ensure seamless interactions. To use this template, you need to be on n8n version 1.50.0 or later.
n8n-team
n8n Team
HTTP Request node
Merge node
+7

Scrape and summarize webpages with AI

This workflow integrates both web scraping and NLP functionalities. It uses HTML parsing to extract links, HTTP requests to fetch essay content, and AI-based summarization using GPT-4o. It's an excellent example of an end-to-end automated task that is not only efficient but also provides real value by summarizing valuable content. Note that to use this template, you need to be on n8n version 1.50.0 or later.
n8n-team
n8n Team
HTTP Request node
Markdown node
+5

AI agent that can scrape webpages

⚙️🛠️🚀🤖🦾 This template is a PoC of a ReAct AI Agent capable of fetching random pages (not only Wikipedia or Google search results). On the top part there's a manual chat node connected to a LangChain ReAct Agent. The agent has access to a workflow tool for getting page content. The page content extraction starts with converting query parameters into a JSON object. There are 3 pre-defined parameters: url** – an address of the page to fetch method** = full / simplified maxlimit** - maximum length for the final page. For longer pages an error message is returned back to the agent Page content fetching is a multistep process: An HTTP Request mode tries to get the page content. If the page content was successfuly retrieved, a series of post-processing begin: Extract HTML BODY; content Remove all unnecessary tags to recude the page size Further eliminate external URLs and IMG scr values (based on the method query parameter) Remaining HTML is converted to Markdown, thus recuding the page lengh even more while preserving the basic page structure The remaining content is sent back to an Agent if it's not too long (maxlimit = 70000 by default, see CONFIG node). NB: You can isolate the HTTP Request part into a separate workflow. Check the Workflow Tool description, it guides the agent to provide a query string with several parameters instead of a JSON object. Please reach out to Eduard is you need further assistance with you n8n workflows and automations! Note that to use this template, you need to be on n8n version 1.19.4 or later.
eduard
Eduard

Implement complex processes faster with n8n

red icon yellow icon red icon yellow icon