From 5ae7de4b39013f88f9407cce46552ca2d663d33d Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 25 Feb 2026 11:13:47 -0800 Subject: [PATCH 1/2] feat(google-sheets): add filter support to read operation --- apps/docs/components/ui/icon-mapping.ts | 12 ++--- apps/docs/content/docs/en/tools/meta.json | 2 +- apps/sim/blocks/blocks/google_sheets.ts | 39 ++++++++++++++++ apps/sim/tools/google_sheets/read.ts | 55 ++++++++++++++++++++++- apps/sim/tools/google_sheets/types.ts | 3 ++ 5 files changed, 103 insertions(+), 8 deletions(-) diff --git a/apps/docs/components/ui/icon-mapping.ts b/apps/docs/components/ui/icon-mapping.ts index 5121253240..7f36adb31a 100644 --- a/apps/docs/components/ui/icon-mapping.ts +++ b/apps/docs/components/ui/icon-mapping.ts @@ -38,8 +38,8 @@ import { EyeIcon, FirecrawlIcon, FirefliesIcon, - GithubIcon, GitLabIcon, + GithubIcon, GmailIcon, GongIcon, GoogleBooksIcon, @@ -72,9 +72,9 @@ import { LinearIcon, LinkedInIcon, LinkupIcon, + MailServerIcon, MailchimpIcon, MailgunIcon, - MailServerIcon, Mem0Icon, MicrosoftDataverseIcon, MicrosoftExcelIcon, @@ -107,6 +107,8 @@ import { ResendIcon, RevenueCatIcon, S3Icon, + SQSIcon, + STTIcon, SalesforceIcon, SearchIcon, SendgridIcon, @@ -118,19 +120,17 @@ import { SimilarwebIcon, SlackIcon, SmtpIcon, - SQSIcon, SshIcon, - STTIcon, StagehandIcon, StripeIcon, SupabaseIcon, + TTSIcon, TavilyIcon, TelegramIcon, TextractIcon, TinybirdIcon, TranslateIcon, TrelloIcon, - TTSIcon, TwilioIcon, TypeformIcon, UpstashIcon, @@ -141,11 +141,11 @@ import { WhatsAppIcon, WikipediaIcon, WordpressIcon, - xIcon, YouTubeIcon, ZendeskIcon, ZepIcon, ZoomIcon, + xIcon, } from '@/components/icons' type IconComponent = ComponentType> diff --git a/apps/docs/content/docs/en/tools/meta.json b/apps/docs/content/docs/en/tools/meta.json index 9fc1cc577e..ce8f8e6b28 100644 --- a/apps/docs/content/docs/en/tools/meta.json +++ b/apps/docs/content/docs/en/tools/meta.json @@ -146,4 +146,4 @@ "zep", "zoom" ] -} +} \ No newline at end of file diff --git a/apps/sim/blocks/blocks/google_sheets.ts b/apps/sim/blocks/blocks/google_sheets.ts index bde2bec45d..768a8f9b31 100644 --- a/apps/sim/blocks/blocks/google_sheets.ts +++ b/apps/sim/blocks/blocks/google_sheets.ts @@ -440,6 +440,36 @@ Return ONLY the range string - no sheet name, no explanations, no quotes.`, placeholder: 'Describe the range (e.g., "first 50 rows" or "column A")...', }, }, + // Read Filter Fields (advanced mode only) + { + id: 'filterColumn', + title: 'Filter Column', + type: 'short-input', + placeholder: 'Column header name to filter on (e.g., Email, Status)', + condition: { field: 'operation', value: 'read' }, + mode: 'advanced', + }, + { + id: 'filterValue', + title: 'Filter Value', + type: 'short-input', + placeholder: 'Value to match against', + condition: { field: 'operation', value: 'read' }, + mode: 'advanced', + }, + { + id: 'filterMatchType', + title: 'Match Type', + type: 'dropdown', + options: [ + { label: 'Contains', id: 'contains' }, + { label: 'Exact Match', id: 'exact' }, + { label: 'Starts With', id: 'starts_with' }, + { label: 'Ends With', id: 'ends_with' }, + ], + condition: { field: 'operation', value: 'read' }, + mode: 'advanced', + }, // Write-specific Fields { id: 'values', @@ -748,6 +778,9 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`, batchData, sheetId, destinationSpreadsheetId, + filterColumn, + filterValue, + filterMatchType, ...rest } = params @@ -836,6 +869,9 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`, cellRange: cellRange ? (cellRange as string).trim() : undefined, values: parsedValues, oauthCredential, + ...(filterColumn ? { filterColumn: (filterColumn as string).trim() } : {}), + ...(filterValue !== undefined && filterValue !== '' ? { filterValue: filterValue as string } : {}), + ...(filterMatchType ? { filterMatchType: filterMatchType as string } : {}), } }, }, @@ -858,6 +894,9 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`, type: 'string', description: 'Destination spreadsheet ID for copy', }, + filterColumn: { type: 'string', description: 'Column header name to filter on' }, + filterValue: { type: 'string', description: 'Value to match against the filter column' }, + filterMatchType: { type: 'string', description: 'Match type: contains, exact, starts_with, or ends_with' }, }, outputs: { // Read outputs diff --git a/apps/sim/tools/google_sheets/read.ts b/apps/sim/tools/google_sheets/read.ts index 2ee88b7c27..0384076a02 100644 --- a/apps/sim/tools/google_sheets/read.ts +++ b/apps/sim/tools/google_sheets/read.ts @@ -154,6 +154,26 @@ export const readV2Tool: ToolConfig 1) { + const headers = values[0] as string[] + const columnIndex = headers.findIndex( + (h) => String(h).toLowerCase() === params.filterColumn!.toLowerCase() + ) + + if (columnIndex !== -1) { + const matchType = params.filterMatchType ?? 'contains' + const filterVal = params.filterValue.toLowerCase() + + const filteredRows = values.slice(1).filter((row) => { + const cellValue = String(row[columnIndex] ?? '').toLowerCase() + switch (matchType) { + case 'exact': + return cellValue === filterVal + case 'starts_with': + return cellValue.startsWith(filterVal) + case 'ends_with': + return cellValue.endsWith(filterVal) + case 'contains': + default: + return cellValue.includes(filterVal) + } + }) + + // Return header row + matching rows + values = [values[0], ...filteredRows] + } + } + return { success: true, output: { sheetName: params?.sheetName ?? '', range: data.range ?? '', - values: data.values ?? [], + values, metadata: { spreadsheetId: metadata.spreadsheetId, spreadsheetUrl: metadata.spreadsheetUrl, diff --git a/apps/sim/tools/google_sheets/types.ts b/apps/sim/tools/google_sheets/types.ts index 74fdc84a1a..2c0c7aa5a4 100644 --- a/apps/sim/tools/google_sheets/types.ts +++ b/apps/sim/tools/google_sheets/types.ts @@ -129,6 +129,9 @@ export interface GoogleSheetsV2ToolParams { includeValuesInResponse?: boolean responseValueRenderOption?: 'FORMATTED_VALUE' | 'UNFORMATTED_VALUE' | 'FORMULA' majorDimension?: 'ROWS' | 'COLUMNS' + filterColumn?: string + filterValue?: string + filterMatchType?: 'contains' | 'exact' | 'starts_with' | 'ends_with' } export type GoogleSheetsV2Response = From 1c5ebcadd878d32e75fc2927dededbf5973089c3 Mon Sep 17 00:00:00 2001 From: waleed Date: Wed, 25 Feb 2026 11:22:27 -0800 Subject: [PATCH 2/2] ran lint --- apps/docs/components/ui/icon-mapping.ts | 12 ++++++------ apps/docs/content/docs/en/tools/meta.json | 2 +- apps/sim/blocks/blocks/google_sheets.ts | 9 +++++++-- apps/sim/tools/google_sheets/read.ts | 1 - 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/docs/components/ui/icon-mapping.ts b/apps/docs/components/ui/icon-mapping.ts index 7f36adb31a..5121253240 100644 --- a/apps/docs/components/ui/icon-mapping.ts +++ b/apps/docs/components/ui/icon-mapping.ts @@ -38,8 +38,8 @@ import { EyeIcon, FirecrawlIcon, FirefliesIcon, - GitLabIcon, GithubIcon, + GitLabIcon, GmailIcon, GongIcon, GoogleBooksIcon, @@ -72,9 +72,9 @@ import { LinearIcon, LinkedInIcon, LinkupIcon, - MailServerIcon, MailchimpIcon, MailgunIcon, + MailServerIcon, Mem0Icon, MicrosoftDataverseIcon, MicrosoftExcelIcon, @@ -107,8 +107,6 @@ import { ResendIcon, RevenueCatIcon, S3Icon, - SQSIcon, - STTIcon, SalesforceIcon, SearchIcon, SendgridIcon, @@ -120,17 +118,19 @@ import { SimilarwebIcon, SlackIcon, SmtpIcon, + SQSIcon, SshIcon, + STTIcon, StagehandIcon, StripeIcon, SupabaseIcon, - TTSIcon, TavilyIcon, TelegramIcon, TextractIcon, TinybirdIcon, TranslateIcon, TrelloIcon, + TTSIcon, TwilioIcon, TypeformIcon, UpstashIcon, @@ -141,11 +141,11 @@ import { WhatsAppIcon, WikipediaIcon, WordpressIcon, + xIcon, YouTubeIcon, ZendeskIcon, ZepIcon, ZoomIcon, - xIcon, } from '@/components/icons' type IconComponent = ComponentType> diff --git a/apps/docs/content/docs/en/tools/meta.json b/apps/docs/content/docs/en/tools/meta.json index ce8f8e6b28..9fc1cc577e 100644 --- a/apps/docs/content/docs/en/tools/meta.json +++ b/apps/docs/content/docs/en/tools/meta.json @@ -146,4 +146,4 @@ "zep", "zoom" ] -} \ No newline at end of file +} diff --git a/apps/sim/blocks/blocks/google_sheets.ts b/apps/sim/blocks/blocks/google_sheets.ts index 768a8f9b31..5c0232555b 100644 --- a/apps/sim/blocks/blocks/google_sheets.ts +++ b/apps/sim/blocks/blocks/google_sheets.ts @@ -870,7 +870,9 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`, values: parsedValues, oauthCredential, ...(filterColumn ? { filterColumn: (filterColumn as string).trim() } : {}), - ...(filterValue !== undefined && filterValue !== '' ? { filterValue: filterValue as string } : {}), + ...(filterValue !== undefined && filterValue !== '' + ? { filterValue: filterValue as string } + : {}), ...(filterMatchType ? { filterMatchType: filterMatchType as string } : {}), } }, @@ -896,7 +898,10 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`, }, filterColumn: { type: 'string', description: 'Column header name to filter on' }, filterValue: { type: 'string', description: 'Value to match against the filter column' }, - filterMatchType: { type: 'string', description: 'Match type: contains, exact, starts_with, or ends_with' }, + filterMatchType: { + type: 'string', + description: 'Match type: contains, exact, starts_with, or ends_with', + }, }, outputs: { // Read outputs diff --git a/apps/sim/tools/google_sheets/read.ts b/apps/sim/tools/google_sheets/read.ts index 0384076a02..7494884727 100644 --- a/apps/sim/tools/google_sheets/read.ts +++ b/apps/sim/tools/google_sheets/read.ts @@ -238,7 +238,6 @@ export const readV2Tool: ToolConfig