> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fliiq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-Built Spotify Skill

> Watch Fliiq build its own Spotify integration from scratch

This walkthrough shows Fliiq's self-generating skill capability in action. A user asked for a Spotify playlist, and the agent built the entire integration mid-conversation.

## The Request

```
User: Create a chill jazz playlist on my Spotify with 15 tracks
```

## What Happened

### 1. Gap Detection

The agent scanned its available skills and found no Spotify integration. It immediately offered to build one:

```
Agent: I don't have a Spotify integration skill. I can build one that
       connects to the Spotify Web API for creating playlists, searching
       tracks, and adding tracks. Want me to create it?
```

### 2. API Research

After getting approval, the agent used `web_search` and `web_fetch` to read the Spotify Web API documentation:

* Endpoint for creating playlists: `POST /v1/users/{user_id}/playlists`
* Endpoint for searching tracks: `GET /v1/search?type=track`
* Endpoint for adding tracks: `POST /v1/playlists/{playlist_id}/tracks`
* Authentication: Bearer token with appropriate scopes

### 3. Template Reference

The agent read the existing `web_search` skill as a template for the 3-file format, noting the pattern of `SKILL.md` + `fliiq.yaml` + `main.py`.

### 4. Skill Generation

The agent generated three files:

**SKILL.md** — Metadata and usage instructions for the LLM:

```markdown theme={null}
---
name: spotify
description: "Create and manage Spotify playlists using the Spotify Web API."
---

Use this tool to create playlists, add tracks, and search for music on Spotify.

## Available Actions
- create_playlist: Create a new playlist
- search_tracks: Search for tracks to add to playlists
- add_tracks_to_playlist: Add tracks to an existing playlist
```

**fliiq.yaml** — Input schema with action-based routing:

```yaml theme={null}
input_schema:
  type: object
  properties:
    action:
      type: string
      enum: ["create_playlist", "search_tracks", "add_tracks_to_playlist"]
    name:
      type: string
      description: "Playlist name"
    query:
      type: string
      description: "Search query for tracks"
    playlist_id:
      type: string
    track_uris:
      type: array
      items:
        type: string
  required:
    - action

credentials:
  - SPOTIFY_CLIENT_ID
  - SPOTIFY_CLIENT_SECRET
  - SPOTIFY_ACCESS_TOKEN
```

**main.py** — Full async handler with three operations, error handling, and batch support for adding tracks (100 per batch, matching Spotify's API limit).

### 5. Installation & Usage

The agent installed the skill via the `install_skill` tool, then immediately:

1. Called `spotify` with `action: search_tracks, query: "chill jazz"` — found 15 tracks
2. Called `spotify` with `action: create_playlist, name: "Chill Jazz"` — created the playlist
3. Called `spotify` with `action: add_tracks_to_playlist` — added all 15 tracks
4. Returned the playlist URL to the user

## Credential Setup

The agent prompted the user to set up Spotify credentials:

1. Create an app at [developer.spotify.com/dashboard](https://developer.spotify.com/dashboard)
2. Set redirect URI to `http://localhost:8888/callback`
3. Get Client ID and Client Secret
4. Generate an access token with `playlist-modify-public` and `playlist-modify-private` scopes

```bash .env theme={null}
SPOTIFY_CLIENT_ID=...
SPOTIFY_CLIENT_SECRET=...
SPOTIFY_ACCESS_TOKEN=...
```

## The Skill Today

This self-generated Spotify skill was later [promoted](/skills/promoting) to a core skill. It now ships with every Fliiq installation:

```bash theme={null}
fliiq skill-list
# spotify  (core)  Create and manage Spotify playlists
```

## Try It Yourself

```bash theme={null}
fliiq run "Search Spotify for 'lo-fi hip hop' and create a study playlist"
```

Or ask Fliiq to build a skill for any API you need:

```bash theme={null}
fliiq run "I need to post messages to my Slack workspace"
# Agent: I don't have a Slack skill. Want me to build one?
```
