Making a Document that Provides Recommendations

To make a document that provides recommendations to the user, all you need to do is state the input you want to analyze and the type of recommendation you want to make in the document’s body. The Logic API will automatically handle the rest. song rec demo

Step 1: Creating the document

For this example, let’s create a document that recommends songs to the user based on their input. The document will analyze the user’s input and provide a recommendation. For the input on this document, we will use the contents of a CSV file of songs from a playlist. It’s easy to convert Spotify playlists to CSV files, and we can use this to create an app that reads from the Spotify API later.

Step 2: Explain the goal

Let’s start by explaining what we want the Logic API to do. We want the document to analyze the user’s input and provide a recommendation based on the input. The document will read from a CSV file of songs from a playlist, analyze the user’s taste, and provide 5 recommendation songs. We want the document to take note of the following:
  • The songs in the playlist
  • The artists of the songs
  • The albums of the songs
  • The release dates of the songs
  • The genres of the songs

Step 3: Explain the input

To give the Logic API some exta context, lets make sure to explain the input we want to analyze. We will be providing a CSV file of songs from a playlist. The CSV file will contain the following data:
CSV file contents
"Track URI","Track Name","Artist URI(s)","Artist Name(s)","Album URI","Album Name","Album Artist URI(s)","Album Artist Name(s)","Album Release Date","Album Image URL","Disc Number","Track Number","Track Duration (ms)","Track Preview URL","Explicit","Popularity","ISRC","Added By","Added At"

Step 4: Give an example

We also want to provide an example of the CSV file contents and an example recommendation.
Examples
Example CSV file input:

"spotify:track:0s1PsjRpN9v3gveUOM6Iux","Neon Roses","spotify:artist:6hQS54VPpxunuwR0W7usuo","The Technicolors","spotify:album:0oWKnbYnV4rzCcZoo6DWP2","Metaphysical","spotify:artist:6hQS54VPpxunuwR0W7usuo","The Technicolors","2017-07-27","https://i.scdn.co/image/ab67616d0000b273384ba1e1ee57378cf6272ae4","1","1","236586","https://p.scdn.co/mp3-preview/434f407ec4075665fe641fa9fb18d91031c477e9?cid=9950ac751e34487dbbe027c4fd7f8e99","false","56","TCADB1731048","spotify:user:romangarms","2024-02-04T07:22:04Z"

"spotify:track:20I8RduZC2PWMWTDCZuuAN","Take Me Out","spotify:artist:0XNa1vTidXlvJ2gHSsRi4A","Franz Ferdinand","spotify:album:0vi5ePiEHrGZJF7QhnDW2z","Franz Ferdinand","spotify:artist:0XNa1vTidXlvJ2gHSsRi4A","Franz Ferdinand","2004-02-16","https://i.scdn.co/image/ab67616d0000b27309a90531b85be7899c3234c4","1","3","237026","https://p.scdn.co/mp3-preview/f91cfdf3dd5f7114cf47f8c8b2567b7a8a76d9ed?cid=9950ac751e34487dbbe027c4fd7f8e99","false","85","GBCEL0300192","spotify:user:romangarms","2024-02-04T07:21:51Z"

"spotify:track:6DjVpyhiisbxSJrUkyoEJx","Restless","spotify:artist:0Z5pcmXDCKTrFWLnDChC37","Miami Horror","spotify:album:0SBHMIlE92TmGMG2uE4puk","Restless","spotify:artist:0Z5pcmXDCKTrFWLnDChC37","Miami Horror","2019-06-28","https://i.scdn.co/image/ab67616d0000b273d7b048b49c00a7c211acb69d","1","1","205948","https://p.scdn.co/mp3-preview/a69d2fac977959055196a6fb9e0b1e7a25d8aa8a?cid=9950ac751e34487dbbe027c4fd7f8e99","false","0","QZGLM1904240","spotify:user:romangarms","2024-02-04T07:23:22Z"

Example Output

These songs are all relatively modern (2004 or newer), all have reasonably complex lyrics. They skew a bit indie, with Franz Ferdinand likely being the most popular.

You might recommend songs by the artist Local Natives, as the songs can be similar genre-wise to The Technicolors. You might recommend other early 2000s one-hit wonders like Franz Ferdinand sometimes is seen as. You might recommend other Miami Horror songs, like those off a more recent album
We want to make sure to set some ground rules for the recommendation. For example, we want to make sure that the recommendation is based on the user’s input and that it is relevant to the user’s input. We also want to make sure we don’t recommend songs that are already in the user’s playlist.

Step 5: Testing this iteration of the document

Using the Preview button, we can test this document to see if it works as expected.
Logic API Output
{
"tasteAnalysis": "Your music taste centers around modern indie pop/rock and synthpop with strong electronic influences. You favor artists from the 2010s and 2020s but appreciate some earlier classics. There's a balance between upbeat, danceable tracks and more introspective or dreamy songs. You enjoy both catchy hooks and thoughtful lyrics, with a preference for atmospheric production and exploring full albums or discographies from your favorite artists.",
"recommendations": [
{
"trackName": "Oblivion",
"artistNames": [
"Grimes"
],
"albumName": "Visions",
"albumReleaseDate": "2012-01-31",
"explanation": "Grimes' blend of synthpop and indie electronic fits perfectly with your love for artists like CHVRCHES and Miami Horror. 'Oblivion' is a modern classic with catchy hooks and atmospheric production."
},
{
"trackName": "Sweet Disposition",
"artistNames": [
"The Temper Trap"
],
"albumName": "Conditions",
"albumReleaseDate": "2009-06-19",
"explanation": "This indie anthem combines soaring vocals with lush instrumentation—ideal for fans of Phoenix, Two Door Cinema Club, and The Technicolors."
},
{
"trackName": "Seventeen",
"artistNames": [
"Sharon Van Etten"
],
"albumName": "Remind Me Tomorrow",
"albumReleaseDate": "2019-01-18",
"explanation": "Sharon Van Etten's modern indie rock sound and emotive delivery will appeal to your appreciation for thoughtful lyrics and atmospheric production."
},
{
"trackName": "Peach",
"artistNames": [
"Broods"
],
"albumName": "Don't Feed the Pop Monster",
"albumReleaseDate": "2019-02-01",
"explanation": "Broods offer a polished blend of indie pop and synth-driven hooks that align well with your playlist's vibe—think CHVRCHES meets BØRNS."
},
{
"trackName": "Youth",
"artistNames": [
"Glass Animals"
],
"albumName": "How To Be A Human Being",
"albumReleaseDate": "2016-08-26",
"explanation": "Glass Animals' 'Youth' brings together dreamy indie pop with electronic textures—perfect for fans of Still Woozy and The Neighbourhood."
}
]
}
When testing this document, the Logic API gave a recommendation based on the user’s input. The document was able to analyze the user’s input and provide a recommendation based on the input. The document also provided a list of songs that were similar to the user’s input. One of the songs that was recommended was by an artist that was already in the user’s playlist. However, it was a new song, and was off of a different album. Three of the other recommendations were by artists that were not in the user’s playlist, but were songs that the user already had in other playlists. This suggests these were accurate recommendations, as the user does already like these songs. One last recommendation was a song that was not in the user’s library at all. The song was by a new artist, and was a similar genre to the user’s input. This is a good recommendation, as the Logic API was able to find completely new music for the user.

Conclusion

In summary, generating a document that provides recommendations is straightforward with the Logic API. By specifying the input to be analyzed and the desired type of recommendation within the document body, the Logic API will automatically perform the necessary processing. Now, you can publish your document and begin using the API to provide recommendations to your users. You could make an app or website that reads from the Spotify API to get the user’s playlists, and also uses the API to create a new playlist with the recommendations.