How to Fake Alexa Notifications

by
Tags:

It’s a known limitation that a custom Alexa skill cannot perform notifications. That is, Alexa can only speak when first spoken to, and cannot spontaneously alert you that you have an appointment coming up or whatever.
There’s a simple way to fake it, though, if you’re using an Echo device and you have a spare computer. The computer can use the Echo as a Bluetooth speaker. Then if you generate an MP3 of Alexa saying something, the computer can play that over the Bluetooth connection, and it sounds like Alexa just spontaneously announced something out of the Echo.
We need to further break this down into two cases:

  1. The alert text is known in advance. You can generate the necessary MP3 file ahead of time. (Procedure below.)
  2. The alert text varies, so the MP3 has to be generated on-demand. This is doable but difficult. You need to use Alexa Voice Services, along with an Alexa Skill where you can manipulate the text in the skill response. For instance, write the text to be spoken to a file or database, where the Alexa skill will read the file or database and say whatever text is in there. Alexa Voice Services will make an MP3 out of that and deliver it to you. The setup is cumbersome though. Here’s an overview of one person’s solution, including the steps needed to configure Alexa Voice Services, but not the custom skill code.

Notifications with Known Alert Text

Sometimes the same event will happen over and over again, so the MP3 file for the notification can be generated in advance. “Hey lazybones, time to walk the dog!” or “Did you know the front door just opened?” or whatever. We’ll just use the same MP3 whenever that event occurs, played over the Echo as a Bluetooth speaker.
Rather than using Alexa Voice Services to capture an MP3, we’ll use our browser’s developer tools. You will still need a custom Alexa skill, but it doesn’t even matter what it is. For instance, the Node.js Hello World example (deployment instructions here) would be fine.
The steps are:

  1. Deploy the custom skill.
  2. Open your browser’s developer tools.
  3. Go to the Alexa Developer Portal and go to the definition of the custom skill.
  4. Go to the Test area for the skill using the left navigation bar.
  5. Enter the text you want in your MP3 file into the “Voice Simulator” field
  6. Click the “Listen” button and make sure she says what you want.
  7. In your browser’s developer tools, look for an XHR request that was just made to https://developer.amazon.com/edw/ajax/getTTS — for instance, in Safari, it’s displayed under Resources and then XHRs, or in Chrome it’s listed under Network.
  8. Select that request and copy and paste the response text to a Web site that does URLDecoding, such as this one. Decode it. The decoded text should look like this: {“contentType”:”audio/mpeg”,”audioFiles”:[“…”]}
  9. Copy the value inside the quotes (not including the quotes) in the “audioFiles” array. Paste it into a Web site that does Base64 decoding and offers a file download for binary content, such as this one. Decode it and download the resulting file.
  10. Rename the file to “notification.mp3” (or whatever MP3 file name you like), and you’re done!

That MP3 file can be played in any of the usual ways over the Bluetooth connection. In our app, we are running an AngularJS app in the browser, so we set the Echo to be the default audio output device on the computer running the browser, and use ngAudio to prepare and play the file. Other people who aren’t already in a Web app seem to pipe the MP3 to a command-line tool that will play it. Whatever works.