Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Promptfoo Promptfoo Google Sheets Integration

From Leeroopedia
Knowledge Sources
Domains Integration, Data_Source
Last Updated 2026-02-14 07:45 GMT

Overview

Concrete tool for reading and writing CSV data from/to Google Sheets, supporting both public (unauthenticated) and private (authenticated) sheets.

Description

The Google_Sheets_Integration module (googleSheets.ts) provides functions to fetch test case data from Google Sheets and write evaluation results back. For public sheets, it uses the CSV export endpoint without authentication. For private sheets, it uses the Google Sheets API v4 with Google Auth library for service account authentication. The module handles sheet selection by gid parameter and header-based row parsing.

Usage

Import these functions when test cases reference Google Sheets URLs (https://docs.google.com/spreadsheets/d/...) in the configuration, or when output is directed to a Google Sheet.

Code Reference

Source Location

Signature

export async function checkGoogleSheetAccess(url: string):
  Promise<{ public: boolean; status?: number }>

export async function fetchCsvFromGoogleSheet(url: string): Promise<CsvRow[]>

export async function writeCsvToGoogleSheet(rows: CsvRow[], url: string): Promise<void>

Import

import { fetchCsvFromGoogleSheet, writeCsvToGoogleSheet } from './googleSheets';

I/O Contract

Inputs

Name Type Required Description
url string Yes Google Sheets URL (with optional gid parameter)
rows CsvRow[] Yes (write) Array of key-value row objects to write

Outputs

Name Type Description
CsvRow[] CsvRow[] Array of parsed rows from the sheet
(void) Promise<void> Write operation completion

Usage Examples

import { fetchCsvFromGoogleSheet, writeCsvToGoogleSheet } from './googleSheets';

// Read test cases from a public Google Sheet
const rows = await fetchCsvFromGoogleSheet(
  'https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms/edit'
);

// Write results back to a different sheet
await writeCsvToGoogleSheet(results, 'https://docs.google.com/spreadsheets/d/.../edit?gid=123');

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment