Simple nodejs Slack app that listens for links to Apple Music albums, artists or tracks and responds with the corresponding link for Spotify.
The service listens to the link_shared
Slack WebAPI event that matches the configured App Unfurl Domains, in this case itunes.apple.com
.
links:read
Slack App Permission Scope is required for this.
Using the id from the shared URL it fetches information about the track/album/artist using the iTunes API (see https://github.com/fvdm/nodejs-searchitunes)
Using the metadata fetched from iTunes it queries the Spotify API for the equivalent item and shares it in the same channel. See https://github.com/thelinmichael/spotify-web-api-node
chat:write:bot
Slack App Permission Scope is required for this.
Note: When using link_shared
and App Unfurl Domains the classic Slack unfurl isn't displayed anymore. This service simulates the classic unfurl using the Metascraper library.
links:write
Slack App Permission Scope is required for this to work.
-
Clone repo and
yarn install
-
- Enable Events Subscription for your app More
- Subscribe to the
link_shared
event - Add
itunes.apple.com
to the App Unfurl Domains - Add
links:read
,links:write
andchat:write:bot
permission scopes
-
Create a Spotify App here
-
Add config as environment variables:
SLACK_SIGNIN_SECRET
- Signing Secret in App CredentialsSLACK_ACCESS_TOKEN
- OAuth Access TokenSPOTIFY_CLIENT_ID
SPOTIFY_CLIENT_SECRET
TEST_ACCESS_TOKEN
- access token used to authorize requests to test endpoints (see below)
-
Start the app with
yarn start
-
Add the Request URL in the Events Subscription page for your Slack App. The url will be
<EXTERNAL_URL>/client/events
. You can use ngrok for local development
The service provides some urls to test the url processing as well as testing iTunes and Spotify querying without the Slack integration. Parameters ar passed as query parameters.
url
- AppleMusic urltoken
- access token, must be the same value asTEST_ACCESS_TOKEN
env variable for the request to be accepted
id
- id of item to query fortoken
- access token, must be the same value asTEST_ACCESS_TOKEN
env variable for the request to be accepted
query
- value to search for as item nametype
- what items to search for, values can be:album
,artist
,track
market
- country code for market where to search for items. Defaults tous
token
- access token, must be the same value asTEST_ACCESS_TOKEN
env variable for the request to be accepted