I want to have my Google Assistant and Home devices (and Mini) respond to a voice command by playing an MP3 file. How can I do this?
Google Assistant's Actions can return a subset of SSML, part of which allows you to instruct the device to play an audio file such as an MP3. An example is given of the SSML to use in the Actions on Google documentation; I've adapted it below for reference:
<speak> Here is an MP3 file. <audio src="https://www.example.com/MY_MP3_FILE.mp3">didn't get your MP3 audio file</audio>. </speak>
This requires you to be developing an Action — the entire process is a little more complex than that, and more detailed information is available directly from Google. If you aren't interested in that, and just want a simple home solution, read on.
Shortcuts can be configured from the Google Home app, as follows:
Menu > More Settings > Shortcuts > Add
Under 'When I say Ok Google', enter your desired phrase
Under 'Google Assistant should do', type 'Play [file name] from my library' after uploading your file to Google Play Music. It's possible that you might need a paid subscription to do this; try it first and see.
Save your shortcut, and give it a try.