Back to Templates

Create custom music tracks from chat using Gemini, Suno via Kei AI, and Google Drive

Created by

Created by: Davide || n3witalia

Davide

Last update

Last update 2 days ago

Share


This workflow creates an AI-powered chatbot that generates custom songs through an interactive conversation, then uploads the results to Google Drive.

This workflow transforms n8n into a complete AI music production pipeline by combining:

  • Conversational AI
  • Structured data validation
  • Tool orchestration
  • External music generation API
  • Cloud automation

It demonstrates a powerful hybrid architecture:
LLM Agent + Tools + API + Storage + Async Control Flow


Key Advantages

1. ✅ Fully Automated AI Music Production

From idea → to lyrics → to full generated track → to cloud storage
All handled automatically.

2. ✅ Conversational UX

Users don’t need technical knowledge.
The AI collects missing information step-by-step.

3. ✅ Smart Tool Selection

The agent dynamically chooses:

  • Songwriter tool (for original lyrics)
  • Search tool (for existing lyrics)

This makes the system adaptive and intelligent.

4. ✅ Structured & Error-Safe Design

  • Strict JSON schema enforcement
  • Output parsing and validation
  • Cleanup of malformed LLM responses

Reduces failure rate dramatically.

5. ✅ Asynchronous API Handling

  • Uses webhook-based resume
  • Handles long-running AI generation
  • Supports multiple song outputs

Scalable and production-ready.

6. ✅ Modular & Extensible

The architecture allows:

  • Switching LLM provider
  • Changing music API
  • Adding new tools (e.g., cover art generation)
  • Supporting different vocal styles or languages

7. ✅ Memory-Enabled Conversations

Uses buffer memory (last 10 messages)
Maintains conversational context and continuity.

8. ✅ Automatic File Management

Generated songs are:

  • Automatically downloaded
  • Properly renamed
  • Stored in Google Drive

No manual file handling required.


How it Works

Here's the flow:

  1. User Interaction: The workflow starts with a chat trigger that receives user messages. A "Music Producer Agent" powered by Google Gemini engages with the user conversationally to gather all necessary song parameters.

  2. Data Collection: The agent collects four essential pieces of information:

    • Song title
    • Musical style (genre)
    • Lyrics (prompt) - either generated by calling the "Songwriter" tool or searched online via the "Search songs" tool
    • Negative tags (styles/elements to avoid)
  3. Validation & Formatting: The collected data passes through an IF condition checking for valid JSON format, then a Code node parses and cleans the JSON output. A "Fix Json Structure" node ensures proper formatting with strict rules (no line breaks, no double quotes).

  4. Song Generation: The formatted data is sent to the Kie.ai API (HTTP Request node) which generates the actual music track. The workflow includes a callback URL for asynchronous processing.

  5. Wait & Retrieve: A Wait node pauses execution until the Kie.ai API sends a webhook callback with the generated songs. The "Get songs" node then retrieves the song data.

  6. Process Results: The response is split out, and a Loop Over Items node processes each generated song individually. For each song, the workflow:

    • Downloads the audio file via HTTP request
    • Uploads it to a specified Google Drive folder with a timestamped filename

Setup steps

  1. API Credentials (3 required):

    • Google Gemini (PaLM) API: Configure in the two Gemini Chat Model nodes
    • Gemini Search API: Set up in the "Search songs" tool node
    • Kie AI Bearer Token: Add in the HTTP Request nodes (Create song and Get songs)
  2. Google Drive Configuration:

    • Authenticate Google Drive OAuth2 in the "Upload song" node
    • Verify/modify the folder ID if needed
    • Ensure the Drive has proper write permissions
  3. Webhook Setup:

    • The Wait node has a webhook ID that needs to be publicly accessible
    • Configure this URL in your Kie.ai API settings as the callback endpoint
  4. Optional Customizations:

    • Adjust the AI agent prompts in the "Music Producer Agent" and "Songwriter" nodes
    • Modify song generation parameters in the Kie.ai API call (styleWeight, weirdnessConstraint, etc.)
    • Update the Google Drive folder path for song storage
    • Change the vocal gender or other music generation settings in the "Create song" node
  5. Testing: Activate the workflow and start a chat session to test song generation with sample requests like "Write a pop song about summer" or "Find lyrics for 'Bohemian Rhapsody' and make it in rock style"


👉 Subscribe to my new YouTube channel. Here I’ll share videos and Shorts with practical tutorials and FREE templates for n8n.

image


Need help customizing?

Contact me for consulting and support or add me on Linkedin.