How to Listen to your Google Voice Voicemail on your Google Home

How to Listen to your Google Voice Voicemail on your Google Home

When the Google Home was first released, it was (and still is) lacking in many features. You still have no way to set calendar events, read your text messages, create a to-do list, and more. However, if you have the gumption, you can implement nearly all of these features on your own, thanks to the power of AutoVoice and Tasker. In an effort to demonstrate just how creative you can be with Google Home and AutoVoice, I will show you how to have your Google Home read your latest Google Voice voicemail. It may seem like black magic right now, but hopefully by the end of this tutorial it will all make sense.

With AutoVoice, you can send spoken commands from your Google Home device to your phone which then interprets these commands and performs some action through Tasker. The best part is that you can send natural language commands to your phone thanks to the power of API.ai, provided you sign up for a $0.99/month subscription service to AutoVoice to offset the cost of hosting the API.ai server. That means you don’t have to speak so robotically/precisely when speaking to your Google Home, and AutoVoice will still recognize the command you are trying to send.

For awhile, AutoVoice integration with Google Home has been in beta, but the release of AutoVoice 3.0 allows all users of the Tasker plug-in to enjoy Google Home integration. Now that AutoVoice is widely available to users and most of its kinks have been ironed out, I will begin showcasing some of the things I’ve made with AutoVoice and Tasker. My first Google Home tutorial, reading your latest Google Voice voicemail, is my most complex to share, but it’s a good candidate to show that what you can do with Tasker is limited only by your imagination.

Listening to my latest voicemail on my Google Home.

Recommended Reading: Check out our previous tutorials, where we show you how to solve common problems that few others have approached. 


Requirements

AutoVoice is a soft requirement for this project to work. You can use IFTTT to trigger the Task, but that will require you to use a workaround involving another application like Join or Pushbullet to send commands to Tasker, as IFTTT does not directly integrate with Tasker. Furthermore, and the most important caveat of not using AutoVoice, is that voice commands will be inflexible if using IFTTT. This means you have to speak your command completely accurately, every single time, or the command won’t trigger. That can be a problem in the future if you start creating tons of Tasker/Google Home integrations (I have 28 currently), meaning you have to memorize and reproduce exactly the commands you want every single time.

You will need:


Preparation

Before we get into the meat of this cool integration, we have to make some preparations for this to work properly. I will approach this setup in parts.

Part 1 – Setting up AutoVoice

I’ve already written at length regarding how to setup AutoVoice with Google Home, so please refer to my previous article here. The only change to really note is that you no longer need AutoVoice beta, as the integration now works with the AutoVoice stable update. I also recommend you read through the short tutorial on making a Tasker profile react to the AutoVoice command, as we will be doing the same thing here. The gist of it is that there are four main things that you will be doing in this setup process:

  1. Enable the AutoVoice service in the Google Home app.
  2. Set up an API.ai account and get your API keys
  3. Add these API keys to the Natural Language setting in AutoVoice
  4. Subscribe to the AutoVoice Natural Language subscription service

Again, these steps are outlined in far greater detail in my previous article, so I recommend you read through it.

Part 2 – Setting up Google Voice

We need a way to access your Google Voice voicemails, so Tasker can extract the voicemail content. The way we will accomplish this is by having all of our voicemails forwarded to your linked Gmail account. This is a native feature of Google Voice, and all you need to do is toggle a single button in the Google Voice app.

Once you’ve done that, you will begin to receive all new voicemails in your e-mail. As you can see, the e-mail contains both a transcription of the voicemail as well as a link to the actual audio of the voicemail. We will be using this e-mail for our purposes.

Part 3 – Setting up AutoWeb

In order to extract the contents of this e-mail, we need to access the e-mail content using the Gmail API. We will do so using the AutoWeb application that was linked near the beginning. Open up AutoWeb and tap on “Browse Web Services.” Scroll down to the Gmail API and tap on it to import. After importing, AutoWeb will ask you to authenticate the Gmail account you want to use with the API. Select the same Gmail account that voicemails are forwarded to.

Now you’ve linked your phone to your Gmail account through the use of the Gmail API!

Part 4 – Setting up AutoCast

Before we can send the voicemail audio to our Google Home, we need to set up AutoCast so it can connect to the Google Home. Open up AutoCast and select “Manage Cast Devices”. Hit the “+” icon in the top bar and select your Google Home device.

Finally, we’re ready to actually get this set up.


Reading your latest Google Voice Voicemail on Google Home

AutoVoice

The first thing we’ll need to do is create an AutoVoice Natural Language command. This is fairly simple to do.

  1. Open up AutoVoice
  2. Tap on Natural Language
  3. Tap on Commands
  4. Tap on the + icon to add a new command
  5. Enter a list of voice commands, separated by commas, containing as many variations of the voice command you think you may speak to trigger this command.
  6. For the responses, you can enter as many responses, or none, that you want the Google Home to read back to you when you speak this command.
  7. Once you’re done, give this command a name. Anything will work here.

Even though you are entering a bunch of variations of commands and responses, you don’t have to worry about remembering to speak these commands exactly as written. API.ai will automatically parse whatever you speak and using its natural language algorithms will match your spoken command to one of the commands you list here.

Alternatively, if you would just like to download my own setup, you can do so at the following link. I believe that for now, in order to import it, you will have to login to API.ai and import it there.

Download the AutoVoice Natural Language Intent

To be honest, the actual AutoVoice portion of this setup is fairly simple, as we aren’t dealing with variables/parameters or contexts in the spoken command. The actual complicated part comes from the next part, where we have Tasker react to this AutoVoice Natural Language command.

Tasker

Here’s a step by step guide of what we’re doing to make this Profile.

  1. Open up Tasker and press the + icon to create a new Profile.
  2. Go to Event –> Plugin –> AutoVoice –> Natural Language.
  3. Tap the pencil icon to open the configuration screen of AutoVoice.
  4. Press “Commands” and select the name of the command you created earlier.
  5. Press the checkmark icon above, then hit the back key to return to Tasker’s main screen.
  6. Tasker will ask you to create a new Task. You can give it a name if you want, but hit the checkmark icon to create a new Task regardless.

Once you are in the Task edit screen, we will be creating the Task that is shown below. To create new Actions, tap on the + icon in the bottom middle. For any Tasker pros here, you can expand the toggle below to show the Profile and Task description you can follow for yourself.

Home - Read Voicemail

 Profile: Home - Read Voicemail (165)
	Event: AutoVoice Natural Language [ Configuration:Commands: read my last voicemail ]
Enter: Read Voicemail (164)
	A1: AutoCast Speak [ Configuration:Device: Bedroom Home Timeout (Seconds):60 ] 
	A2: AutoWeb Web Service [ Configuration:API: Gmail
API Action: List messages
Include spam trash: false
User ID: me
Search: from:voice-noreply@google.com
Max Results: 5 Timeout (Seconds):120 ] 
	A3: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ] 
	A4: AutoWeb Web Service [ Configuration:API: Gmail
API Action: Get Message
Format: full
User ID: me Timeout (Seconds):120 ] 
	A5: For [ Variable:%headers Items:1:%payload_headers_name(#) ] 
	A6: Variable Set [ Name:%reference To:%headers Recurse Variables:Off Do Maths:Off Append:Off ] If [ %payload_headers_name(%headers) ~ Subject ]
	A7: End For 
	A8: Java Function [ Return:decodedbody Class Or Object:Base64 Function:decode
{byte[]} (String, int) Param:%bodydata(1) Param:8 Param: Param: Param: Param: Param: ] 
	A9: Java Function [ Return:%body Class Or Object:String Function:new
{String} (byte[], String) Param:decodedbody Param:UTF-8 Param: Param: Param: Param: Param: ] 
	A10: Variable Split [ Name:%body Splitter:https://www.google.com/voice/fm/ Delete Base:Off ] 
	A11: Variable Split [ Name:%body2 Splitter:> Delete Base:Off ] 
	A12: HTTP Get [ Server:Port:https://www.google.com Path:/voice/fm/%body21 Attributes: Cookies: User Agent: Timeout:10 Mime Type:audio/* Output File:/sdcard/Tasker/voicemail.mp3 Trust Any Certificate:Off ] 
	A13: Variable Set [ Name:%voicemail To:%payload_headers_value(%reference) Recurse Variables:Off Do Maths:Off Append:Off ] 
	A14: Variable Split [ Name:%voicemail Splitter:from Delete Base:Off ] 
	A15: Variable Split [ Name:%voicemail2 Splitter:at Delete Base:Off ] 
	A16: Test Phone [ Type:Contact Name Data:%voicemail21 Store Result In:%name Continue Task After Error:On ] 
	A17: Variable Set [ Name:%voicemail To:%voicemail1 from %name at %voicemail22 Recurse Variables:Off Do Maths:Off Append:Off ] If [ %name Set ]
	A18: Variable Set [ Name:%voicemail To:%voicemail1 from %voicemail21 at %voicemail22 Recurse Variables:Off Do Maths:Off Append:Off ] If [ %name !Set ]
	A19: AutoCast Speak [ Configuration:Device: Bedroom Home
Text: %voicemail Timeout (Seconds):60 ] 
	A20: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] 
	A21: AutoCast [ Configuration:
Starting Casting Screen
Persistent Notification: true
Cast Device: Bedroom Home
Screen: Full Screen Media
Audio: /storage/emulated/0/Tasker/voicemail.mp3
Audio Volume: 100
Audio Position: 0
Audio AutoPlay: true Timeout (Seconds):3000 ]

The below step-by-step guide will show you how to replicate the Task, shown in the screenshot to the right. The Task is the meat of this setup here, and it is fairly complex. How it works is that once the Profile is activated, the first few actions (A2-A4) searches and pulls from your Gmail account for messages from voice-noreply@google.com, which is the automated e-mail service used by Google Voice. We then look for the subject header (A5-A7) so we can get the information about who sent the voicemail and when. Next we extract the message body of the Gmail message, which is encoded in base 64 so we have to use a Java function (A8-A9). After we’ve retrieved the decoded message, we then look for the URL that links us to the voicemail audio file (A10-A11) and finally download the file as an mp3 (A12). A13-A18 simply looks up the contact information, if it exists, for the number that left the voicemail. Finally, A19-A21 will read out who the voicemail was sent from at what time as well as the recorded voicemail audio.

  1. Plugin –> AutoCast –> AutoCast Speak. Device: pick your Google Home. (No text is necessary here, this is just to connect to the Google Home.)
  2. Plugin –> AutoWeb. API: Gmail. API Action: List messages. User ID: me. Search: from:voice-noreply@google.com. Max results: 5. Output: Id.
  3. Task –> Wait. Wait 1 second.
  4. Plugin –> AutoWeb. API: Gmail. API Action: Get Message. Format: full. User ID: me. Message ID: %aid(1). Output: Body Data, Payload Headers Name, and Payload Headers Value.
  5. Task –> For. Variable: %headers. Items: 1:%payload_headers_name(#)
  6. Variables –> Variables Set. Name: %reference. To: %headers. Check If and set it to If %payload_headers_name(%headers) ~ Subject.
  7. Task –> End For.
  8. Code–> Java Function. For the Class/Object, select Base64. Function: decode {byte[]} (String, int). Param (string): %bodydata(1). Param (int): 8. Return: decodedbody.
  9. Code –> Java Function. For the Class/Object, select String. Function: new {String} (byte[], String). Param (byte[]): decodedbody. Param (string): UTF-8. Return: %body.
  10. Variables –> Variable Split. Name: %body. Splitter: https://www.google.com/voice/fm/
  11. Variables –> Variable Split. Name: %body2. Splitter: >
  12. Net –> HTTP Get. Server:Port: https://www.google.com Path: /voice/fm/%body21 Mime Type: audio/* Output File: /sdcard/Tasker/voicemail.mp3
  13. Variables –> Variable Set. Name: %voicemail. To: %payload_headers_value(%reference)
  14. Variables –> Variable Split. Name: %voicemail. Splitter: from
  15. Variables –> Variable Split. Name: %voicemail2. Splitter: at
  16. Phone –> Test Phone. Type: Contact Name. Data: %voicemail21. Store Result in: %name. Make sure to check continue task after error.
  17. Variables –> Variable Set. Name: %voicemail. To: %voicemail1 from %name at %voicemail22. Check if at the bottom and set it to if %name is set.
  18. Variables –> Variable Set. Name: %voicemail. To: %voicemail1 from %voicemail21 at %voicemail22. Check if at the bottom and set it to if %name isn’t set.
  19. Plugin –> AutoCast –> Speak. Device: pick your Google Home. Text: %voicemail
  20. Task –> Wait. Wait 5 seconds. This is a configurable delay to ensure that there’s always enough time between the announcement of the new voicemail and the voicemail audio being played. If this is too short, you can increase this time. Play around with this value though to see what reduces the delay to an acceptable level.
  21. Plugin –> AutoCast –> AutoCast. Cast Device: pick your Google Home again. Select full screen media as the Screen. Go to Full Screen Media elements, then Audio, and for the Audio (“song to play”) put /sdcard/Tasker/voicemail.mp3. Select Auto Play.

That’s it! Now, all you need to do to trigger this Task is to send the command to your Google Home device. You can do so by saying “Hey/OK Google, let me talk to AutoVoice” and then speaking one of the variations of your command when AutoVoice tells you to say your command. Or you can say your command all in one go by saying “Hey/OK Google, ask AutoVoice to [command]” just like I did in the video shown in the beginning.


Download Profile

You can download the Tasker profile/task I made at the below link. If you choose to do so, make sure that you go in and modify the two “AutoCast” Actions so that they reference your particular Google Home device. Also, check to make sure that the AutoVoice Natural Language Command named in my Profile is the same as the one you made. If not, just change the Profile to point to your command. Should take just a few seconds.

Download the Home – Read Voicemail Tasker Profile

Once you’ve downloaded the above XML file, save it anywhere on your device. Open Tasker and disable Beginner Mode in preferences. Then go back to the main screen and long-press on the Profiles tab up tap until you see a pop-up box with “Import” as an option. Press that and navigate to where you saved the .prf.xml file and select it to import it.

I hope you found this tutorial useful. I enjoyed tinkering with the API and Tasker until I was able to get things working. I know it isn’t super elegant, but this is mostly a showcase of how powerfully you can integrate your Google Home with various web services and your phone. Hopefully this inspires you to create something you didn’t think was possible before!

Discuss This Story

You might also like