Prevent Web Calls to Chromecast from Interrupting Existing Playing Music

We just bought a Google Home and I’ve been playing around with Home Assistant with it and the myriad of Chromecasts we have around the house. Right now, I have been using a relatively simple web service call from IFTTT to trigger the API to use the TTS engine. It’s using google Say and the JSON is just

"{"entity_id":"media_player.desktop_speakers","message":"David has left work."}"

However, I would like to upgrade this to either (a) resume any media which was already playing which it interrupted, or (b) not play anything if it’s going to interrupt something.

Is the best option here to do some scripting and use that to determine if something is playing on a particular chromecast, then have the web service call the script instead?

I’m brand new to json and YAML, but I have some solid experience with scripting so I’m sure I’ll be able to figure out the language. Just wondering if it’s generally possible and if anybody has any experience with it.