AppsScriptPulse

Listing free Udemy courses in Google Sheets with the Udemy API and Apps Script

Learn how to use the Udemy API with Google Apps Script to find free programming courses on Udemy on any topic.

A double win in this post from Amit Agarwal. Not only can you get a list of free programming courses currently running on Udemy, but Amit includes the code snippet used to get/add these to a Google Sheet. This might be useful if you are working with other APIs and are looking for a code snippet to help format the data in a Google Sheets friendly format.

Source: Find Free Udemy Courses with Google Sheets and the Udemy API – Digital Inspiration

Automating the creation of multiple folders in Google Drive with Google Apps Script (with a nice Google Sheet processing code pattern)

 

you can use the following Apps Script to create folders in Google Drive for students and share those folders with their email addresses based on data from a Google Sheet

Whilst this post from Amit Agarwal looks at the automatic creation of Google Drive folders, it’s also worth having a look at it at for an Apps Script pattern for iterating over and processing data from Google Sheets. In particular there is a getStudentData()function that turns the 2D array return from .getValues() into an object array which includes a rowIndex. This makes it easy to update your Google Sheet when each row is processed.

Source: Automating the Creation of Multiple Folders in Google Drive – Digital Inspiration

How to efficiently read email messages with the Gmail API and Google Apps Script batch requests

There are two ways to pull email addresses from Gmail messages. The simpler, and more popular, method is that you pull a list of messages from which you wish to extract the email and loop over them to extract the email addresses. A more efficient way to pull email addresses from multiple email messages is to make a single batch request to the Gmail API with the help of Apps Script’s UrlFetch service.

We’ve featured a couple of posts on how you can make batch requests with Google Workspace APIs. With the limited runtime in Apps Script using batches can be an invaluable tool to finish your script in the execution limit and also improve your user experience. In this particular example for Amit Agarwal he looks at how batch requests can be made to the Gmail API by first get message details from a call to Gmail.Users.Messages.list, before getting message details in a single UrlFetchApp.fetchAll call. All the example code is included in the source post and to get to execute it copy/paste/run the following function:

const app = () => {
  const messageIds = searchGmailMessages();
  makeBatchRequest(messageIds);
}

Source: How to Efficiently Read Email Messages with the Gmail API and Apps Script – Digital Inspiration

How you can use Google Docs to write and execute Google Apps Script code

Image credit: Amit Agarwal (labnol.org)

There is a way to use Google Docs as a programming IDE and run JavaScript code inside the editor …  It is no replacement for a dedicated IDE like Visual Studio code but Google Docs can be used as a JavaScript playground to quickly run code snippets.

A familiar story I hear is people with no formal coding experience starting their developer journey with Google Apps Script. I find being able to run small snippets of code are a great way to learn and a number of sites like W3 Schools and also increasingly Stack Overflow include the ability to ‘try it yourself’ with inline code runners.

If you are looking to support users getting started with Google Apps Script Amit Agarwal has this little code snippet which lets you inline/run Google Apps Script code in Google Docs. There are both limitations and considerations with this approach but as a quick way for learners to run and collaborate on small snippets, which can be contextualised with explanatory text/resources, it’s a nice starting point. Check out the source link for more details.

Source: How to Use Google Docs as a Code Runner – Digital Inspiration

How to send personalized text messages from Google Sheets (and make user friendly add-ons)

The Document Studio add-on helps you automatically send text messages when a new Google Form is submitted or when new rows are added to Google Sheets. You can thus build workflows that send text reminders when the invoices are due. Or you can get notified instantly when people fill out your Google Forms.

There was some speculation this week about how much revenue Amit Agarwal (Digital Inspiration) makes through his suite of Google Workspace Add-ons. I can neither confirm or deny the reported figures, but what I’m certain of is Amit is not only an expert developer but also clearly very talented at spotting opportunities and creating very slick user experiences.

This latest post from Amit is a case in point. No code, but plenty of screenshots demonstrating how users of his Document Studio add-on can integrate a SMS text service into Google Forms/Sheets. As this is achieved with a Webhook integration users aren’t limited to SMS services. Click through to the source link to see more screenshots similar to the one below:

Source: How to Send Personalized Text Messages from Google Sheets – Digital Inspiration

How to preserve formatting of Google Forms responses in Google Sheets with Google Apps Script

Learn how to automatically preserve the formatting in Google Sheet when new Google Form responses are submitted.

Handy little Apps Script snippet from Amit Agarwal should you need to keep any custom formatting applied to linked Google Forms responses in Google Sheets. Another way you can approach this is using ARRAYFORMULA to reference the form responses in another sheet and apply your desired formatting.

The default ‘Form responses’ sheet can be hidden if needed. Downside of using ARRAYFORMULA is you are referencing a cell range which can cause confusion when using features like sort. See the source link for all the code used in Amit’s solution.

Source: How to Auto Format Google Form Responses in Google Sheets – Digital Inspiration

How to send WhatsApp messages from Google Sheets using the WhatsApp API [and Google Apps Script] – Digital Inspiration

Learn how to use the WhatsApp API to send personalized messages from Google Sheets to your WhatsApp contacts.

The question of how to automate WhatsApp using Google Apps Script has come up several times in the community forums. This has been notoriously difficult and also unreliable as Workspace developers had to often find workarounds without easy access to the WhatsApp Business API.

A recent announcement from Meta has made this much easier with the introduction of the WhatsApp Business Cloud API:

Send and receive messages using a cloud-hosted version of the WhatsApp Business Platform. The Cloud API allows you to implement WhatsApp Business APIs without the cost of hosting of your own servers and also allows you to more easily scale your business messaging.

Amit Agarwal hasn’t wasted any time in publishing a growing number of tutorials specifically for Google Apps Script developers and Google Workspace users on sending messages to WhatsApp. This first tutorial from Amit provides information on setting up a WhatsApp application on the Meta developers website and the Apps Script code required to send a message.

Source: How to Send WhatsApp Messages from Google Sheets using the WhatsApp API – Digital Inspiration

How to schedule a meeting in Google Meet with Apps Script – Digital Inspiration

Learn how to setup a video meeting inside Google Meet with the Google Calendar API and Apps Script. This Apps Script sample shows how you can programmatically schedule video meetings inside Google Meet with one or more participants using the Google Calendar API. It can be useful for teachers who wish to schedule regular meetings with their students but instead of manually creating meeting invites, they can easily automate the whole process for the entire class.

We’ve featured a couple of Google Meet scheduling solutions in Pulse[1,2]. This latest example from Amit Agarwal includes some nice code examples for additional optional parameters that can be used when using Google Calendar as an Advanced Service (Calendar.Events.insert). These include:

  • attendees[].responseStatus – for setting the attendee’s response status;
  • reminders.overrides[] – to override default event reminders and pops; and
  • recurrence[] – creating a custom recurrence for the calendar event

Amit includes some very useful examples of recurrence rules, using the RRULE notation. As well as RRULE the recurrence property can also accept RDATE and EXDATE values for further occurrence customisation.

Source: How to Schedule a Meeting in Google Meet with Apps Script – Digital Inspiration

  1. Phil Bainbridge’s Bulk create Google Calendar events with optional Meet or Zoom
  2. Luke Craig’s Using Google Apps Script to schedule Google Meets for a Virtual Parents’ Evening Assistant

How to Auto-Download Podcasts to Google Drive with Google Sheets [and Google Apps Script] – Digital Inspiration

You use Google Sheets as your own Podcast Manager that will automatically download your favorite podcasts to Google Drive and instantly sync across all your devices.

Amit Agarwal is always coming up with creative uses for Google Apps Script. His latest project is a great example of what can be achieved with a little code and a lot of know-how. Even if you aren’t a podcast fan this project is worth checking out as Amit is expert at writing concise and efficient code.

Some highlights to check out once you make a copy of the ‘Podcast Manager’ Google Sheet are use of CacheService for getting/putting a last update time and using the .filter(Boolean) trick for ignoring blank cells when using .getValues() on Google Sheets data. There is plenty more going on and worth spending some time using the Script Editor debugger and breakpoints to learn from a master.

Source: How to Auto-Download Podcasts to Google Drive with Google Sheets – Digital Inspiration

How to extract text from PDF files with Google Apps Script – Digital Inspiration

Image credit: Amit Agarwal

This tutorial explains how you can parse and extract text elements from invoices, expense receipts and other PDF documents with the help of Apps Script.

We’ve previously featured a method for extracting text from a PDF from Scott Donald. This latest post from Amit Agarwal uses a similar technique of sending a PDF document to Google Drive API to convert to a text file and then using RegEx to extract the content you need. Given the number of PDF documents flying around between organisations both of these posts from Amit and Scott are worth being aware of for potential future projects.

Source: How to Extract Text from PDF Files with Google Apps Script – Digital Inspiration