Google Apps Script, Webhooks, API(mutation)

Hi Team, this is a working example of code that I thought might be useful to the community. It serves to automate creating a folder system for clients in Google drive and adding those URLs to clients in Monday. I’m not very code savvy, so there are some not so clean workarounds for the query string. Thanks @dipro and @akashub for examples that I based this on.

What my script does:
When I add a new item/client on Monday this sends a webhook to a Google SS Web App, the Web App script is triggered, the Google Apps Script then creates a drive folder (which acts as a document bucket for the item/client) lastly the Script returns an API mutation call to Monday and loads the google drive URL into the a text col in the item/client.

Authentication Script
Working Script

Here are the end to end steps involved:

  1. Create Google Sheets SS
  2. Via SS open Script Editor
  3. Add authentication code
  4. Deploy as web app with settings - Who has access to the app: Anyone, even anonymous. + copy url
  5. Setup monday webhook via integration + paste copied url = verified webhook
  6. Back in Apps Script - Delete authentication code + paste working code
  7. Modify code variables with your API key, Google Drive Folder ID, API query string, API variables string
  8. Trigger webhook via
  9. Done!

Apologies my API query string is particularly messy, but I couldn’t work out how to stringify this. Working out how to get your query string correct is a pain. The reason I capture data to the spreadsheet was to help with this. If you are struggling with API call, here is my process if you want to create a different API POST / change different stuff via the API:

  1. Test query + variables in Monday “Try it yourself” API env.
  2. trigger webhook
  3. capture webhook JSON in SS + copy data to postman
  4. test via postman (remember the output you’re looking to recreate via postman is found in the “Code” tab found under the Save Button :wink:
  5. Good luck!

Please feel free to ask questions, and hopefully answers to better format my code and better test the API query.


Hey @cdcrm - welcome to the community!

Thank you so much for sharing that - hopefully others in the community find this and use it :slight_smile: