English

Malay

This automation trick may actually change your life.

Before we dive into the technical details, imagine something powerful: automating the creation of personalised letters for hundreds of people—generating each letter, converting them to PDFs, emailing them, and even tracking their status—all with just one click. This is exactly what this solution offers.

But that’s not where it ends. Once you understand how this automation works, you can apply it to much more than letters. Think about automating invoices, contracts, certificates, event invitations, or any repetitive task that involves merging data and documents. The potential to save time and reduce manual effort is enormous. Automate reports, schedule follow-ups, or generate custom documents on demand for your team—whatever fits your needs.

The real power of automation lies in its flexibility. Using tools like Google Apps Script and ChatGPT, you can build custom workflows tailored specifically to your tasks—without needing to be a coder. By the end of this tutorial, you’ll have the knowledge to automate key workflows, freeing up your time to focus on more important work.

So, let’s get started and explore how you can unlock the full potential of automation!

Apps used:

  1. Google Sheets
  2. Google Docs
  3. Google Drive
  4. Gmail
  5. ChatGPT
Merge Letters Workflow Illustration
**An illustration of the entire workflow

The workflow

Step 1: Getting your assets ready

Before you start getting the codes, prepare the 3 assets that you need.

1. Google Sheets – the file containing names and email addresses
  1. Create a new Google Sheets (**called ‘Merge Letters’) and name the columns of data that you want to display in the custom letter, add a column called ‘Status’ at the end so that we see confirmation that the letter has been sent out. Eg, ‘Name’, ‘Address1’, ‘Address2’, ‘Email’, ‘Status’
  2. The spreadsheet can contain an almost unlimited number of columns and data that you can ‘push’ into a Google Docs to create personalised letters.
  3. Take note of the Sheets file ID in the URL bar. ID is written in blue for example: https://docs.google.com/spreadsheets/d/1uh6XO0z5Bn0hchY_loSM1KnW1LF3ajuV1IVD5ObftrY/edit?usp=sharing
Create Your Google Sheets
2. Google Docs – the letter template
  1. Create a new Docs file (**called ‘Letter Template’) and draft out the letter to be sent out to the respondents.
  2. Where you want to pull the data from the spreadsheet and insert into a line, use the curly braces {} to define the placeholders.
  3. Example: {{Name}}, {{Address1}}, {{Address2}}
  4. Ensure that the capitalization of the placeholders match the ones in your spreadsheet.
  5. Take note of the Docs file ID in the URL bar. ID is written in blue for example: https://docs.google.com/document/d/1xg-_ZMrUMhbVBI_DDqdriwZMVm2xLJSJTKSpWC_itv8/edit?usp=sharing
Create Your Google Docs Template
3. Google Drive – where the letters are stored
  1. Create a new folder (**called ‘Sent Letters’) that will save the PDFs of the letters that have been personalised and sent out.
  2. Take note of the folder ID in the URL bar. ID is written in blue for example: https://drive.google.com/drive/folders/1WIGQgOSDNTErac4AqjfPI-aSXyBXqxBs
Create Your Google Drive Folder

**File and folder names can be anything you want them to be. Do the next step only when you completed the above steps.

Step 2: ChatGPT – getting the code and executing it

1. Prompting in ChatGPT (Important)
“I need help writing a Google Apps Script that automates the creation of personalized letters. I have a Google Sheet with client details like name, address1, address2, address3 and email, and a last column called ‘Status.’ I want to use a Google Docs template with placeholders for each data point. The script should add a custom menu in Google Sheets to trigger the operation, automatically generate personalized letters as PDFs, and save them to a specific folder in Google Drive. Then, it should email the PDF to each client and update the ‘Status’ column in the Google Sheet to show ‘Sent’ once the letter is successfully sent. Finally, display a message to the user once the operation is completed. Could you help me write the code for this?”

This is just an example prompt—you don’t need to copy it exactly. Feel free to adjust the wording to better fit your situation/scenario.

Prompting in ChatGPT
2. Examine ChatGPT’s Output for Instructions
  • The second step is to examine the output displayed by ChatGPT, it should contain instructions on how to execute the code in Google Apps Script.

Note: you will never get the same output even with using the same prompt, this is just the nature of using Gen AI tools. It should be fine, but if you run into problems, simply re-prompt and try again.

Examine ChatGPT's Output for Instructions
3. Open Google Apps Script Editor
  • Next, in the Sheets that you’ve created, click Extensions -> Google Apps Script to open up the script editor.
Open Google Apps Script Editor
3. Delete & Replace Code
  • Delete the default script that you see in the editor.
  • Copy the code from ChatGPT and paste it into Google Apps Script.
Delete & Replace Code
4. Replace IDs & Run The Script
  • Replace the Docs and Drive ID in the script.
  • Save and Run the script.
Replace IDs & Run The Scripts
5. Review Permissions & Authorising

Allow permissions for Google Apps Script to run & execute, follow the steps below.

  • Click “OK” or “Review Permission” when you see “Authorisation Required”
  • Select your Google Account
  • When you see “Google hasn’t verified this app”, click on “Advanced” on the bottom left, click on the “(unsafe)” option. *If you don’t see this option, just proceed & select allow.
  • Then select “Allow” at the last section
  • Note: Running the script is completely safe when you are running it on your own account, have a second thought when you are allowing others to access your files.
  • Look at the image below to have a better idea of the entire authorisation process.
Review Permissions & Authorising
Step by Step Guide to Authorise the Script
**Step-by-step guide on autorisation.
6. Find The Newly Created ‘Custom Menu’ on Your Google Sheets Menu Bar
  • The custom menu should appear on your Google Sheets Interface (if not, simply refresh the browser), click and run the function.
Find The Newly Created 'Custom Menu' on Your Google Sheets Menu Bar
7. Waiting For “Running Script”
  • The script will begin pulling data from Sheets and merging the data into Docs. If you run into any errors, double check the file and folder IDs and copy the error and paste it into ChatGPT and ask it to resolve the error.
Waiting For Running Script
8. Script Runs Successfully!
  • If everything runs smoothly, you will receive a confirmation message saying that the operation completed successfully.
Script Runs Successfully!
9. Status Column Updated
  • In Sheets, you will see that the Status column is updated to ‘Sent’ for each row.
Status Column Updated
10. Ensure Files Are Generated & Saved in Your Google Drive Folder
  • Check Google Drive and see that the letters have been converted into PDF.
Ensure Files Are Generated & Saved in Your Google Drive Folder
11. Ensure The Document Content Is Correct.
  • Check the generated PDF to ensure that the data has been merged successfully. (The placeholders have been replaced by the data in your Google Sheets.)
Ensure The Document Content Is Correct
12. Ensure Emails Are Sent Out
  • Finally, check that the email has been sent out along with the customised PDF letter.
Ensure Emails Are Sent Out
If you have reached here, congratulations!
Or did you meet any problem? Well look at how you could troubleshoot below.

Troubleshooting

  • If the placeholder does not display the data, check the placeholders spelling in both the spreadsheet and Google Docs file.
  • If you receive any errors when running the script, copy and paste the error code into ChatGPT.
  • If you find yourself troubleshooting too long, start again from the beginning.

Conclusion

So, did you successfully deploy the code? Pretty easy, right? It’s amazing to think that you just went through this entire process without spending anything and without needing to know how to code—all by simply prompting a Gen AI tool. Technology has truly come a long way.

Now, take a moment to think about how you can apply this skill in your daily work. Whether it’s automating the creation of certificates, generating personalized letters, or streamlining other repetitive tasks, there are endless possibilities.

Consider your current workflow—where could automation save you time and effort? How can you use this newfound skill to make your work more efficient and impactful? Start brainstorming ideas, and who knows, you might find new ways to optimize your day-to-day tasks.

By Ali Reza Azmi

Founder & Consultant @ Twenty-Four Consulting

By Ali Reza Azmi

Founder & Consultant @ Twenty-Four Consulting

Automation can be Super EASY, and FREE.

With Google Apps Script & Gen AI, you don't need to be a coder to automate anymore!

Watch our demo, download our free cheat sheet, and join the waitlist today.

Google Apps Script Waitlist Image

Related Posts