Skip to content
NEWMarketplace and your team: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / AI Agents & Assistants

AI Agents & Assistants

Calculate stock replenishment from Excel reports using Google Drive and OpenAI

Watches a Google Drive folder for new XLSX inventory reports, uses GPT-4.1 mini to compute reorder quantities and reasons per batch, and writes the results back to the file.

What it does

## Calculate stock replenishment from an Excel report with AI ### How it works 1. A Google Drive trigger watches a folder for new XLSX inventory reports. 2. The file is downloaded, parsed and split into batches of 15 rows. 3. For each batch, a Code node builds a compact product list (sales, purchases, warehouse and store stock) and GPT-4.1 mini returns how many units to reorder plus a one-sentence reason. 4. The answers are written back to each row as columns AB (need) and AC (reason). 5. All rows are reassembled in order, converted back to XLSX, the original file is updated and moved to an output folder. ### Setup - [ ] Google Drive: in Google Cloud Console (cloud.google.com) create an OAuth Client ID and Client Secret and add them as a Google Drive credential - [ ] Pick the folder to watch in Trigger_XLSX_Uploaded_to_Drive - [ ] Once Drive is connected, open Download XLSX, Update Sheet and Move To New Folder so they use the credential, and choose your output folder - [ ] OpenAI: add your API key credential to Message a model - [ ] Replace MARKA ADI in the system prompt with your brand name ### Customization The Code nodes and AI prompt are built around one specific spreadsheet's column names, so other files will need changes: - Paste the Code node scripts and the AI prompt into ChatGPT, share your column names or upload your Excel file, and ask it to adapt them - Change batchSize in Code: ChunkToBatches to balance speed and token usage

The steps

  1. Loop Over Items
  2. Code: ChunkToBatches
  3. Code: BuildPrompt
  4. Code: MapBack
  5. Code: Reassemble
  6. Extract from XLSX
  7. Convert to XLSX
  8. Download XLSX
  9. Trigger_XLSX_Uploaded_to_Drive
  10. Move To New Folder
  11. Update Sheet
  12. Message a model

Similar automations