HG can easily perform a task on motion with a script (Wizard, C#, etc). If your desired action is web based (call to a web page), HG can definitely do it quite easily. If you have some other way to call the command via a command line, HG can also do that easily. If you need to construct something more complex (send json to an app or something), HG can probably do it, but it may require more programming experience. I don't know how to interface with Spotify.
The alternative is to push the event to your device and have the device parse the command to do something. That might be easier if the tablet is the one controlling the music currently.