How to display the currently playing Spotify track as your Teams status message

Yes, you read that right.

Let’s acknowledge the sheer importance of what you’re about to read.

Think of the cultural, teamwork, and employee benefits. This is possibly the most important thing you can implement as a user, in your Microsoft 365 environment.

No, you’re right… this particular thing is completely and utterly useless.

The Challenge?

I honestly couldn’t think of how in any universe this would benefit a single person – be it you sharing the information, or other people reading it. There are a number of existing social tools and apps that will show what you’re currently playing, but this is the worksplace.

Personally, it just came about as I had been experimenting with a couple of other things in Power Apps & Automate, and one morning while walking the dog I wondered if this was at all possible. (yes, I think of what workflows I can build while walking the dog – don’t you!?)

I thought, maybe let’s put “Current mood is based on: <Spotify track info>” but thought that it wasn’t accurate as sometimes my music choice is driven by the mood as well as the other way around. Plus, how does that make any difference to my colleagues?

Do I have the right to be angry in a call just because I was listening to Sepultura or Fear Factory?

Do I have the right to be crass and joking just because I was listening to The Lonely Island?

The Solution?

Yeah ok, enough faff, on with the “solution”. How can I inform my colleagues what I’m currently listening to on Spotify currently? Because it’s clearly so important to me…

Spotify has publicly available APIs which are well document and clearly laid out. The first challenge was the fact that the only way for Spotify to trigger anything was to use the Web Client SDK, which was well beyond my comfort zone as I am not a coder. So opted for the lazy man’s “trigger” – a workflow that runs on an interval. And because songs have differing track lengths, I opted to have it run every 5 minutes between 9am and 6pm. Yes, yes I did. Because it’s that important.

I followed the instructions in this great blog post that explains how to create a custom connector for Power Platform, which can be used for the GET request: https://thatapiguy.tech/2019/12/08/spotify-custom-connector-for-power-platform/

So now that we have our “trigger” and initial data collection, how do we get this into our Teams status message? No Microsoft Graph required here. Because of the importance of this solution, we’re going to use endpoints that are undocumented and unsupported. And we’re going to use a Power Automate action that is completely unrelated.

You can read about how to use the Send an HTTP request to SharePoint connector to set your Teams status here: https://www.damobird365.com/teams-status-update-via-power-automate/

Here’s what the final workflow looks like:

A couple of the key features of this workflow:

  • The status message is set to expire at the end of the song
  • If Spotify is paused or not running the workflow ends without updating your Teams status message

Breaking down the workflow

Let’s start with our trigger:

From here we initialise some variables and parse the output to help with text cleanup and presentation later:

Once we’ve got that, we then need to calculate the time when this status message should expire – ideally the end of the track.

To do that, we take away our current progress from the duration, and because it’s all in milliseconds we divide by 1,000 to give us seconds:

Now we add those seconds to the current time:

Now that we’ve done the maths, let’s get the data out. Firstly – a condition that if the track isn’t currently playing, we should stop the workflow. If it is, continue on and sift through the JSON data to set the artist & track variables:

The reason for the apply to each is because the artist data shows up in both the album and track information. I’m sure that step could’ve been done better, but workflow efficiency wasn’t exactly a priority.

From here we put the two together:

And finally, we post it to Teams:

And then at 4:50pm it changes to:

Summary

Is this important for anyone? No, I’m fairly sure nobody would find this valuable at all.

It was simply a gimmick that I was playing with, and seeing as I figured it out, I thought I may as well share it.

I’m sure the workflow structure and method could be better, but that really wasn’t the priority here. If you’ve got some suggestions for improvements, let me know.

Otherwise, if you want the Flow to install yourself and can’t get it going from the screenshots – let me know.

And yes, this workflow will continue to run while I’m on holidays, at lunch, listening to music in my car or at any time I’m running Spotify during business hours.

Which for the most part is fine as I’m not embarrassed by my musical taste, which is quite eclectic. However, as I have two young daughters and over time have come to enjoy listening to Taylor Swift, The Spice Girls, Katy Perry, The Wiggles, Big Block Singsong, etc. And there’s been a few times where I’ve played them for my own enjoyment, so it’ll be interesting to see if any of my colleagues comment…


Also published on Medium.

5 comments

  1. Enjoyed enormously following this, and getting it to work (only my second Power Automate effort, and I know no coding), only to find out it violates our admin data policy. Ces’t la vie!

  2. Can you elaborate more on the Parse JSON step, as well as how in “Condition” you were offered “is_playing”? I only have “body”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.