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.
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?
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.
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.
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 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.
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…
{
    “type”: “object”,
    “properties”: {
        “timestamp”: {
            “type”: “integer”
        },
        “context”: {
            “type”: “object”,
            “properties”: {
                “external_urls”: {
                    “type”: “object”,
                    “properties”: {
                        “spotify”: {
                            “type”: “string”
                        }
                    }
                },
                “href”: {
                    “type”: “string”
                },
                “type”: {
                    “type”: “string”
                },
                “uri”: {
                    “type”: “string”
                }
            }
        },
        “progress_ms”: {
            “type”: “integer”
        },
        “item”: {
            “type”: “object”,
            “properties”: {
                “album”: {
                    “type”: “object”,
                    “properties”: {
                        “album_type”: {
                            “type”: “string”
                        },
                        “artists”: {
                            “type”: “array”,
                            “items”: {
                                “type”: “object”,
                                “properties”: {
                                    “external_urls”: {
                                        “type”: “object”,
                                        “properties”: {
                                            “spotify”: {
                                                “type”: “string”
                                            }
                                        }
                                    },
                                    “href”: {
                                        “type”: “string”
                                    },
                                    “id”: {
                                        “type”: “string”
                                    },
                                    “name”: {
                                        “type”: “string”
                                    },
                                    “type”: {
                                        “type”: “string”
                                    },
                                    “uri”: {
                                        “type”: “string”
                                    }
                                },
                                “required”: [
                                    “external_urls”,
                                    “href”,
                                    “id”,
                                    “name”,
                                    “type”,
                                    “uri”
                                ]
                            }
                        },
                        “available_markets”: {
                            “type”: “array”,
                            “items”: {
                                “type”: “string”
                            }
                        },
                        “external_urls”: {
                            “type”: “object”,
                            “properties”: {
                                “spotify”: {
                                    “type”: “string”
                                }
                            }
                        },
                        “href”: {
                            “type”: “string”
                        },
                        “id”: {
                            “type”: “string”
                        },
                        “images”: {
                            “type”: “array”,
                            “items”: {
                                “type”: “object”,
                                “properties”: {
                                    “height”: {
                                        “type”: “integer”
                                    },
                                    “url”: {
                                        “type”: “string”
                                    },
                                    “width”: {
                                        “type”: “integer”
                                    }
                                },
                                “required”: [
                                    “height”,
                                    “url”,
                                    “width”
                                ]
                            }
                        },
                        “name”: {
                            “type”: “string”
                        },
                        “release_date”: {
                            “type”: “string”
                        },
                        “release_date_precision”: {
                            “type”: “string”
                        },
                        “total_tracks”: {
                            “type”: “integer”
                        },
                        “type”: {
                            “type”: “string”
                        },
                        “uri”: {
                            “type”: “string”
                        }
                    }
                },
                “artists”: {
                    “type”: “array”,
                    “items”: {
                        “type”: “object”,
                        “properties”: {
                            “external_urls”: {
                                “type”: “object”,
                                “properties”: {
                                    “spotify”: {
                                        “type”: “string”
                                    }
                                }
                            },
                            “href”: {
                                “type”: “string”
                            },
                            “id”: {
                                “type”: “string”
                            },
                            “name”: {
                                “type”: “string”
                            },
                            “type”: {
                                “type”: “string”
                            },
                            “uri”: {
                                “type”: “string”
                            }
                        },
                        “required”: [
                            “external_urls”,
                            “href”,
                            “id”,
                            “name”,
                            “type”,
                            “uri”
                        ]
                    }
                },
                “available_markets”: {
                    “type”: “array”,
                    “items”: {
                        “type”: “string”
                    }
                },
                “disc_number”: {
                    “type”: “integer”
                },
                “duration_ms”: {
                    “type”: “integer”
                },
                “explicit”: {
                    “type”: “boolean”
                },
                “external_ids”: {
                    “type”: “object”,
                    “properties”: {
                        “isrc”: {
                            “type”: “string”
                        }
                    }
                },
                “external_urls”: {
                    “type”: “object”,
                    “properties”: {
                        “spotify”: {
                            “type”: “string”
                        }
                    }
                },
                “href”: {
                    “type”: “string”
                },
                “id”: {
                    “type”: “string”
                },
                “is_local”: {
                    “type”: “boolean”
                },
                “name”: {
                    “type”: “string”
                },
                “popularity”: {
                    “type”: “integer”
                },
                “preview_url”: {
                    “type”: “string”
                },
                “track_number”: {
                    “type”: “integer”
                },
                “type”: {
                    “type”: “string”
                },
                “uri”: {
                    “type”: “string”
                }
            }
        },
        “currently_playing_type”: {
            “type”: “string”
        },
        “actions”: {
            “type”: “object”,
            “properties”: {
                “disallows”: {
                    “type”: “object”,
                    “properties”: {
                        “resuming”: {
                            “type”: “boolean”
                        },
                        “skipping_prev”: {
                            “type”: “boolean”
                        }
                    }
                }
            }
        },
        “is_playing”: {
            “type”: “boolean”
        }
    }
}
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!
Can you elaborate more on the Parse JSON step, as well as how in “Condition” you were offered “is_playing”? I only have “body”
Are you able to share a screenshot of what yours looks like?
It might also be worthwhile checking out this post (https://www.m365princess.com/blogs/level-up-flows/) where Luise cleans up my workflow and does away with the Parse JSON step entirely.
I ran into trouble with hers as well but largely because I’m still new at this. Luise’s connector must be different than the one you created because I didn’t get the option to configure the Body in the one I created using the directions found here – https://thatapiguy.tech/2019/12/08/spotify-custom-connector-for-power-platform/
Using your method, I got to the Parse JSON part just like Codi and didn’t know what to put in the Schema section …. and thats where it stopped for me.
Sorry for the delay. Have just updated the post with the schema at the end of it.
Can you copy/paste a schema from “Parse JSON” step? Doesn’t seem to generate in my instance. Thanks!
Sorry for the delay. Have just updated the post with the schema at the end of it.
Thank you Loryan, for sharing with us!
I was wondering where did you get the endpoint URL to call in your workflow?
I wanted to build a background service that would update my status message based on my calendar + adding some comments about when I’m going to be back.
First thing I wanted to check is how the authentication keys/tokens could be issued and then see the endpoints but I didn’t find any documentation using the URL you provided. Is it kind of internal API that wasn’t supposed to be used by public?
Thank you!
Which endpoint do you mean? The one for actually updating my status, or getting the data from Spotify?
If the former – it’s not an officially supported endpoint so use it with a grain of salt.
Hello Loryan, sorry for the confusion
I was talking about the MS API for updating the status message. It makes sense now, thank you for the clarification!
Hi Loran, for me it’s a loved feature. I used to have similar things in the past with Skype-Spotify or Messenger-Spotify. Now I’ll add this feature as soon as I find time to create the flow. Music is important in my life, so thank you so muuuuch!!!
Loran, I loved this. Honestly, much of it a smidge above my current knowledge, but I’m leading a new team at a new company and would love to implement this for culture-building reasons. I would also LOVE to implement for Apple Music. Thoughts? Is there any “download this flow” option to integrate?
Thanks for the feedback Patrick. At one point this was over my head too, which is why I shared it (as silly as it is). Apple Music has an API, so hopefully you can make it work. https://developer.apple.com/documentation/applemusicapi
In terms of downloading the flow, I can share the exported version, but you’d still have to build the custom connector manually and probably modify other chunks too.
I know of several people that have never built a flow before this one, so while I can appreciate that it would seem daunting – it’s certainly possible. Plus it might make for a good group activity. 🙂
Loryan – it was a truly blind endeavor, but I pulled it off with great thanks to you. Here’s my rundown of the process: https://patricksprague.wordpress.com/2022/04/20/update-microsoft-teams-status-with-apple-music-now-playing/
Well done, very brave of you to take it on with no prior Power Automate experience. Kudos to you!
Hi there, Loryan! I DO find this so valuable, interesting and useful. I’ll tell you how it works for me as soon as I can try this trick. Thanks for sharing! 🙂
Thank you so much Sir for this essential flow!! It should be integrated natively to Teams!
Where does the actoin is playing come from in the condition ?
It comes from the “Get Current Song” action, second from the top.
I’ll try it later. But I just loved the idea. It bring back memories of MSN messenger.
1am here, waiting for app team to do their job on some servers… thinking that i could do some useless clicks, thinking what is the least required “thing” to have … coming to an idea if teams can show “currently playing” from spotify, putting some words together in google and landing here. now i know what i’m going to do while waiting!
No, you’re right… this particular thing is completely and utterly useless.
yes indeed, utterly useless for 99% of earth population, but for us weirdos this is a must because we can.
thanks a million lad!
Thanks Martin, I’m glad you’re on the same wavelength!