Skip to content

Commit 31ccaa5

Browse files
authored
feat(google-drive): added additional tools to interact with google drive (#387)
* added additional google drive tools * added folder id and doc id fields for google docs and google drive, added additional google drive tools * added google drive upload to list of google drive tools * consolidated consts * resolved PR comments
1 parent d2cf31b commit 31ccaa5

File tree

20 files changed

+674
-382
lines changed

20 files changed

+674
-382
lines changed

apps/docs/content/docs/tools/google_drive.mdx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Google Drive
3-
description: Upload, download, and list files
3+
description: Create and list files
44
---
55

66
import { BlockInfoCard } from '@/components/ui/block-info-card'
@@ -72,7 +72,7 @@ In Sim Studio, the Google Drive integration enables your agents to interact dire
7272

7373
## Usage Instructions
7474

75-
Integrate Google Drive functionality to manage files and folders. Upload new files, download existing ones, and list contents of folders using OAuth authentication. Supports file operations with custom MIME types and folder organization.
75+
Integrate Google Drive functionality to manage files and folders. Upload new files, get content from existing files, create new folders, and list contents of folders using OAuth authentication. Supports file operations with custom MIME types and folder organization.
7676

7777
## Tools
7878

@@ -104,22 +104,23 @@ Upload a file to Google Drive
104104
| `modifiedTime` | string |
105105
| `parents` | string |
106106

107-
### `google_drive_download`
107+
### `google_drive_create_folder`
108108

109-
Download a file from Google Drive
109+
Create a new folder in Google Drive
110110

111111
#### Input
112112

113-
| Parameter | Type | Required | Description |
114-
| ------------- | ------ | -------- | ----------------------------------------- |
115-
| `accessToken` | string | Yes | The access token for the Google Drive API |
116-
| `fileId` | string | Yes | The ID of the file to download |
113+
| Parameter | Type | Required | Description |
114+
| ------------- | ------ | -------- | ------------------------------------------------------- |
115+
| `accessToken` | string | Yes | The access token for the Google Drive API |
116+
| `fileName` | string | Yes | Name of the folder to create |
117+
| `folderId` | string | No | ID of the parent folder \(leave empty for root folder\) |
117118

118119
#### Output
119120

120121
| Parameter | Type |
121122
| ---------------- | ------ |
122-
| `metadata` | string |
123+
| `file` | string |
123124
| `name` | string |
124125
| `mimeType` | string |
125126
| `webViewLink` | string |
@@ -159,15 +160,19 @@ List files and folders in Google Drive
159160

160161
## Block Configuration
161162

162-
No configuration parameters required.
163+
### Input
164+
165+
| Parameter | Type | Required | Description |
166+
| ----------- | ------ | -------- | ----------- |
167+
| `operation` | string | Yes | Operation |
163168

164169
### Outputs
165170

166-
| Output | Type | Description |
167-
| ------------ | ------ | ------------------------ |
168-
| `response` | object | Output from response |
169-
|`content` | string | content of the response |
170-
|`metadata` | json | metadata of the response |
171+
| Output | Type | Description |
172+
| ---------- | ------ | --------------------- |
173+
| `response` | object | Output from response |
174+
|`file` | json | file of the response |
175+
|`files` | json | files of the response |
171176

172177
## Notes
173178

apps/docs/content/docs/tools/thinking.mdx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,27 @@ import { BlockInfoCard } from '@/components/ui/block-info-card'
99
type="thinking"
1010
color="#181C1E"
1111
icon={true}
12-
iconSvg={`<svg className="block-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="currentColor">
13-
<title>Brain</title>
14-
<g id="Brain">
15-
<path d="M11,5.34c-.12,1,.26.66-1,.66A7,7,0,0,0,4.85,17.75,7,7,0,0,0,2.62,28.48,12.14,12.14,0,0,0,.06,37.22C1,46.59,12.33,51.56,19.31,45A11.66,11.66,0,0,0,23,36.51V6.22C23-1.57,11.86-2.14,11,5.34Zm-.55,40.55a8.89,8.89,0,0,1-4.78-2.18l.42-.42a2.1,2.1,0,0,1,2.42-.4,1,1,0,0,0,.9-1.78c-2-1-1.24.83-2-3.11-.61-3,1.55-4.14,0-4.89-1.79-.9-2.38,3.32-2,5.28.79,4,.85,1.7-1.19,3.94a10,10,0,0,1-.13-12.5c1.51,1,4.86,2,4.86.17a1,1,0,0,0-1-1c-5.79,0-6.94-8.33-1.27-9.82C8,19.87,11,20.73,11,19a1,1,0,0,0-1-1,5,5,0,1,1,1.44-9.77C13,12,18,13,18,11a1,1,0,0,0-1-1,4,4,0,1,1,4-3.78v9.37l-1.16,1.15a3.42,3.42,0,0,1-4.29.43,1,1,0,0,0-1.38.28c-1.12,1.68,3.7,3.68,6.83.92V36.51A9.3,9.3,0,0,1,10.49,45.89Z" />
16-
<path d="M16.21,23.79a3.14,3.14,0,0,0-4.42,0c-1,1-2-.42-3.08-1.5a1,1,0,0,0-1.42,1.42l.86.85-1.47.49A1,1,0,0,0,7.32,27L10.18,26c2.71.74,3.26-2.15,4.61-.79l2.5,2.5a1,1,0,0,0,1.42-1.42Z" />
17-
<path d="M17,33H16a3,3,0,0,0-3,3,1,1,0,0,1-1,1H11a1,1,0,0,0,0,2h1a3,3,0,0,0,3-3,1,1,0,0,1,1-1h1A1,1,0,0,0,17,33Z" />
18-
<path d="M45.36,28.49a7,7,0,0,0-2.21-10.74A7,7,0,0,0,38,6c-1.28,0-.93.35-1-.63A6,6,0,0,0,31,0a6.13,6.13,0,0,0-6,6.22V36.51C25,42.89,30.26,48.4,36.82,48A12,12,0,0,0,45.36,28.49Zm-1.65,13.8A4.92,4.92,0,0,0,42,41c.55-2.79,1.21-4.79-.13-7.47a1,1,0,0,0-1.78.9c1,2.06.45,3.65-.07,6.25-3.33.28-1.92,2.85-.59,2.19s2.33.34,2.88.84A9.28,9.28,0,0,1,27,36.51V18.37c3.12,2.75,8,.76,6.83-.92a1,1,0,0,0-1.38-.28,3.42,3.42,0,0,1-4.29-.43L27,15.59V6.22A4,4,0,1,1,31,10a1,1,0,0,0-1,1c0,2.05,5.07,1,6.57-2.78A5,5,0,1,1,38,18a1,1,0,0,0,0,2,7,7,0,0,0,3.27-.82C47,20.68,45.73,29,40,29a1,1,0,0,0,0,2,6.89,6.89,0,0,0,3.86-1.17C48.62,35.85,44,42.55,43.71,42.29Z" />
19-
<path d="M41,27a1,1,0,0,0,.32-1.95l-1.47-.49.86-.85a1,1,0,0,0-1.42-1.42c-1.09,1.09-2.07,2.51-3.08,1.5a3.14,3.14,0,0,0-4.42,0l-2.5,2.5A1,1,0,0,0,30,28c.56,0,.54-.13,3.21-2.79,1.38-1.38,1.86,1.54,4.61.79C40.92,27,40.78,27,41,27Z" />
20-
<path d="M37,37H36a1,1,0,0,1-1-1,3,3,0,0,0-3-3H31a1,1,0,0,0,0,2h1a1,1,0,0,1,1,1,3,3,0,0,0,3,3h1A1,1,0,0,0,37,37Z" />
21-
</g>
12+
iconSvg={`<svg className="block-icon"
13+
14+
xmlns="http://www.w3.org/2000/svg"
15+
16+
17+
viewBox="0 0 24 24"
18+
fill="none"
19+
stroke="currentColor"
20+
strokeWidth="2"
21+
strokeLinecap="round"
22+
strokeLinejoin="round"
23+
>
24+
<path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" />
25+
<path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z" />
26+
<path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4" />
27+
<path d="M17.599 6.5a3 3 0 0 0 .399-1.375" />
28+
<path d="M6.003 5.125A3 3 0 0 0 6.401 6.5" />
29+
<path d="M3.477 10.896a4 4 0 0 1 .585-.396" />
30+
<path d="M19.938 10.5a4 4 0 0 1 .585.396" />
31+
<path d="M6 18a4 4 0 0 1-1.967-.516" />
32+
<path d="M19.967 17.484A4 4 0 0 1 18 18" />
2233
</svg>`}
2334
/>
2435

apps/sim/app/api/files/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ export const contentTypeMap: Record<string, string> = {
5555
ts: 'application/typescript',
5656
// Document formats
5757
pdf: 'application/pdf',
58+
googleDoc: 'application/vnd.google-apps.document',
5859
doc: 'application/msword',
5960
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
6061
// Spreadsheet formats
6162
xls: 'application/vnd.ms-excel',
6263
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
64+
googleSheet: 'application/vnd.google-apps.spreadsheet',
6365
// Presentation formats
6466
ppt: 'application/vnd.ms-powerpoint',
6567
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
@@ -71,6 +73,8 @@ export const contentTypeMap: Record<string, string> = {
7173
svg: 'image/svg+xml',
7274
// Archive formats
7375
zip: 'application/zip',
76+
// Folder format
77+
googleFolder: 'application/vnd.google-apps.folder',
7478
}
7579

7680
/**

apps/sim/blocks/blocks/google_docs.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,17 @@ export const GoogleDocsBlock: BlockConfig<GoogleDocsResponse> = {
7777
title: 'Or Enter Document ID Manually',
7878
type: 'short-input',
7979
layout: 'full',
80-
placeholder: 'ID of the document (from URL)',
81-
condition: {
82-
field: 'operation',
83-
value: 'read',
84-
and: { field: 'documentId', value: '' },
85-
},
80+
placeholder: 'ID of the document',
81+
condition: { field: 'operation', value: 'read' },
8682
},
8783
// Manual Document ID for write operation
8884
{
8985
id: 'manualDocumentId',
9086
title: 'Or Enter Document ID Manually',
9187
type: 'short-input',
9288
layout: 'full',
93-
placeholder: 'ID of the document (from URL)',
94-
condition: {
95-
field: 'operation',
96-
value: 'write',
97-
and: { field: 'documentId', value: '' },
98-
},
89+
placeholder: 'ID of the document',
90+
condition: { field: 'operation', value: 'write' },
9991
},
10092
// Create-specific Fields
10193
{
@@ -106,9 +98,23 @@ export const GoogleDocsBlock: BlockConfig<GoogleDocsResponse> = {
10698
placeholder: 'Enter title for the new document',
10799
condition: { field: 'operation', value: 'create' },
108100
},
101+
// Folder Selector for create operation
102+
{
103+
id: 'folderSelector',
104+
title: 'Select Parent Folder',
105+
type: 'file-selector',
106+
layout: 'full',
107+
provider: 'google-drive',
108+
serviceId: 'google-drive',
109+
requiredScopes: [],
110+
mimeType: 'application/vnd.google-apps.folder',
111+
placeholder: 'Select a parent folder',
112+
condition: { field: 'operation', value: 'create' },
113+
},
114+
// Manual Folder ID for create operation
109115
{
110116
id: 'folderId',
111-
title: 'Parent Folder ID (Optional)',
117+
title: 'Or Enter Parent Folder ID Manually',
112118
type: 'short-input',
113119
layout: 'full',
114120
placeholder: 'ID of the parent folder (leave empty for root folder)',
@@ -149,22 +155,16 @@ export const GoogleDocsBlock: BlockConfig<GoogleDocsResponse> = {
149155
}
150156
},
151157
params: (params) => {
152-
const { credential, documentId, manualDocumentId, ...rest } = params
158+
const { credential, documentId, manualDocumentId, folderSelector, folderId, ...rest } =
159+
params
153160

154-
// Use the selected document ID or the manually entered one
155-
// If documentId is provided, it's from the file selector and contains the file ID
156-
// If not, fall back to manually entered ID
157161
const effectiveDocumentId = (documentId || manualDocumentId || '').trim()
158-
159-
if (params.operation !== 'create' && !effectiveDocumentId) {
160-
throw new Error(
161-
'Document ID is required. Please select a document or enter an ID manually.'
162-
)
163-
}
162+
const effectiveFolderId = (folderSelector || folderId || '').trim()
164163

165164
return {
166165
...rest,
167166
documentId: effectiveDocumentId,
167+
folderId: effectiveFolderId,
168168
credential,
169169
}
170170
},
@@ -176,6 +176,7 @@ export const GoogleDocsBlock: BlockConfig<GoogleDocsResponse> = {
176176
documentId: { type: 'string', required: false },
177177
manualDocumentId: { type: 'string', required: false },
178178
title: { type: 'string', required: false },
179+
folderSelector: { type: 'string', required: false },
179180
folderId: { type: 'string', required: false },
180181
content: { type: 'string', required: false },
181182
},

0 commit comments

Comments
 (0)