Save your Google Voicemail to Google Drive as MP3 Files

When you receive a voicemail message on a phone number connected to your Google Voice account, the text transcription of the voice mail is emailed to your Gmail account along with a link to play the audio message on your phone or desktop. Now you can automatically save that voice mail to your Google Drive as an MP3 file.

Google Voicemail as MP3

I have written a little web app that scans your Gmail mailbox for any voicemails from Google Voice and it will save the audio in a specific folder on your Google Drive. The app attaches the voicemail transcript to the MP3 file as well thus making it possible for you to search your voice mails from within Google Drive.

To get started, click here and authorize why the app to access your Gmail and Google Drive accounts. On the next screen, click the Google Voice button and wait for the app to initialize. That’s it. The app will run in the background and monitor your Gmail account for any messages from Google Voicemail.

It creates a new folder called Google Voice in your Google Drive and all the voicemail MP3 files are saved in this folder. Also, once a voice mail has been processed in Gmail, a new label called MP3 is applied to that message to prevent the app from reprocessing that email message.

The app is powered by Google Scripts and the entire source code is available below. You can stop the script anytime using the uninstallation link that would have arrived in your Gmail account when you authorized the app.

Google Script - Save Voice Mail as MP3 in Google Drive

/* Written by Amit Agarwal amit@labnol.org   */
/* Tutorial: http://www.labnol.org/?p=25153  */

var folder,
  folder_name = 'Google Voice';
var archive,
  gmail_label = 'MP3';

/* Find Google Voice messages in Gmail */

var filter = 'from:voice-noreply@google.com -label:' + gmail_label;
var threads = GmailApp.search(filter, 0, 10);

if (threads.length) {
  /* Google Drive folder where the MP3 files will get stored */
  var folders = DriveApp.getFoldersByName(folder_name);
  folder = folders.hasNext() ? folders.next() : DriveApp.createFolder(folder_name);

  /* Gmail Label that is applied to processed voice mails */
  archive = GmailApp.getUserLabelByName(gmail_label)
    ? GmailApp.getUserLabelByName(gmail_label)
    : GmailApp.createLabel(gmail_label);

  for (var x = 0; x < threads.length; x++) {
    threads[x].addLabel(archive);

    var msg = threads[x].getMessages()[0];

    /* Find the link to play the voice mail message */
    var url = msg.getBody().match(/https?:\/\/www.google.com\/voice\/fm[^\"]*/gi);

    if (url) {
      /* Find the name of the voice sender (or their phone number) */
      var file_name = msg.getSubject().match(/new voicemail from (.*) at /i);

      /* Add the voice mail date to the file name */
      var file_date = Utilities.formatDate(msg.getDate(), Session.getScriptTimeZone(), 'yyyy-MM-dd HH:mm');

      if (file_name) {
        /* Extract the audio file and save as an MP3 file */
        var mp3 = url[0].replace('/voice/fm/', '/voice/media/svm/');
        var file = folder.createFile(UrlFetchApp.fetch(mp3).getBlob());

        /* Save the voice mail transcript with the audio file */
        file.setName(file_name[1] + ' [' + file_date + ']' + '.mp3');
        file.setDescription(msg.getPlainBody());
      }
    }
  }
}

PS:The script triggers every 15 minutes and processes 10 voice mail messages in the batch starting with the most recent ones. If you have too many old voice mails in your Gmail account, it may take a while to process all the emails.

[**] The web app requires permissions to access your Gmail and Google Drive. I have shared the full source code of the app but if you aren’t convinced yet, just make a copy of the above code in your Google Drive and run it manually.

Also see: Save Gmail Attachments to Google Drive

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

0

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.