This script automates sending data from a Google Sheet to Gemini Pro and pasting the generated response back into the sheet. Learn to Use Gemini Pro inside Google Sheets.

Steps to Use Gemini Pro inside Google Sheets
- Set Up Your Google Sheet
- Ensure your sheet has:
- Column _ (or any column you choose) with input text.
- Column _ (or your preferred column) where responses will be stored.
- Update the script with your actual sheet name.
- Ensure your sheet has:

- Add the Script to Google Sheets
- Open your Google Sheet.
- Click Extensions → Apps Script.
- Delete any existing code and paste the provided script.

- Update the Configuration
- Change these constants at the top of the script if needed:
sheetName
: Your Google Sheet’s name.inputColumn
: Column containing data to process (default is B).outputColumn
: Column to store results (default is E).apiKey
: Replace with your actual Gemini Pro API key.prompt
: Enter your prompt.model
: Provide the model name.
- Change these constants at the top of the script if needed:
- Run the Script
- Save the code
- Click the Run button in the Apps Script editor.
- Authorize the script if prompted.
- The script will process data from the input column and fill the output column.
- How It Works
- Reads data from the input column.
- Sends each entry to Gemini for processing.
- Saves the AI-generated response in the output column.
- Skips rows that already have responses to avoid overwriting.
- Error Handling
- Errors (e.g., API issues) will be logged in Apps Script Logger.
- If an issue occurs, check View → Logs in the Apps Script editor.
Download n8n Template of Automated Kids Story (Free download)