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.
Here are the end to end steps involved:
- Create Google Sheets SS
- Via SS open Script Editor
- Add authentication code
- Deploy as web app with settings - Who has access to the app: Anyone, even anonymous. + copy url
- Setup monday webhook via integration + paste copied url = verified webhook
- Back in Apps Script - Delete authentication code + paste working code
- Modify code variables with your API key, Google Drive Folder ID, API query string, API variables string
- Trigger webhook via monday.com
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:
- Test query + variables in Monday “Try it yourself” API env.
- trigger webhook
- capture webhook JSON in SS + copy data to postman
- test via postman (remember the output you’re looking to recreate via postman is found in the “Code” tab found under the Save Button
- Good luck!
Please feel free to ask questions, and hopefully answers to better format my code and better test the API query.