Skip to content

Commit 5d19bbd

Browse files
authored
Google sheets (#201)
1 parent 7af72b0 commit 5d19bbd

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

mint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@
175175
"tools/toolkits/docker",
176176
"tools/toolkits/duckdb",
177177
"tools/toolkits/duckduckgo",
178+
"tools/toolkits/desi_vocal",
178179
"tools/toolkits/e2b",
179180
"tools/toolkits/email",
180181
"tools/toolkits/exa",
182+
"tools/toolkits/eleven_labs",
181183
"tools/toolkits/fal",
182184
"tools/toolkits/financial_datasets",
183185
"tools/toolkits/firecrawl",
@@ -187,6 +189,7 @@
187189
"tools/toolkits/google_maps",
188190
"tools/toolkits/googlecalendar",
189191
"tools/toolkits/googlesearch",
192+
"tools/toolkits/googlesheets",
190193
"tools/toolkits/hackernews",
191194
"tools/toolkits/jina_reader",
192195
"tools/toolkits/jira",

tools/toolkits/google_sheets.mdx

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Google Sheets
3+
---
4+
5+
**GoogleSheetsTools** enable an Agent to interact with Google Sheets API for reading, creating, updating, and duplicating spreadsheets.
6+
7+
## Prerequisites
8+
9+
You need to install the required Google API client libraries:
10+
11+
```bash
12+
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
13+
```
14+
15+
Set up the following environment variables:
16+
17+
```bash
18+
export GOOGLE_CLIENT_ID=your_client_id_here
19+
export GOOGLE_CLIENT_SECRET=your_client_secret_here
20+
export GOOGLE_PROJECT_ID=your_project_id_here
21+
export GOOGLE_REDIRECT_URI=your_redirect_uri_here
22+
```
23+
24+
## How to Get Credentials
25+
26+
1. Go to Google Cloud Console (https://console.cloud.google.com)
27+
2. Create a new project or select an existing one
28+
3. Enable the Google Sheets API:
29+
- Go to "APIs & Services" > "Enable APIs and Services"
30+
- Search for "Google Sheets API"
31+
- Click "Enable"
32+
33+
4. Create OAuth 2.0 credentials:
34+
- Go to "APIs & Services" > "Credentials"
35+
- Click "Create Credentials" > "OAuth client ID"
36+
- Go through the OAuth consent screen setup
37+
- Give it a name and click "Create"
38+
- You'll receive:
39+
* Client ID (GOOGLE_CLIENT_ID)
40+
* Client Secret (GOOGLE_CLIENT_SECRET)
41+
- The Project ID (GOOGLE_PROJECT_ID) is visible in the project dropdown at the top of the page
42+
43+
## Example
44+
45+
The following agent will use Google Sheets to read and update spreadsheet data.
46+
47+
```python cookbook/tools/googlesheets_tools.py
48+
from agno.agent import Agent
49+
from agno.tools.googlesheets import GoogleSheetsTools
50+
51+
SAMPLE_SPREADSHEET_ID = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
52+
SAMPLE_RANGE_NAME = "Class Data!A2:E"
53+
54+
google_sheets_tools = GoogleSheetsTools(
55+
spreadsheet_id=SAMPLE_SPREADSHEET_ID,
56+
spreadsheet_range=SAMPLE_RANGE_NAME,
57+
)
58+
59+
agent = Agent(
60+
tools=[google_sheets_tools],
61+
instructions=[
62+
"You help users interact with Google Sheets using tools that use the Google Sheets API",
63+
"Before asking for spreadsheet details, first attempt the operation as the user may have already configured the ID and range in the constructor",
64+
],
65+
)
66+
agent.print_response("Please tell me about the contents of the spreadsheet")
67+
68+
```
69+
70+
## Toolkit Params
71+
72+
| Parameter | Type | Default | Description |
73+
| ------------------ | --------------- | ------- | --------------------------------------------------------------------------- |
74+
| `scopes` | `List[str]` | `None` | Custom OAuth scopes. If None, determined by operations. |
75+
| `spreadsheet_id` | `str` | `None` | ID of the target spreadsheet. |
76+
| `spreadsheet_range`| `str` | `None` | Range within the spreadsheet. |
77+
| `creds` | `Credentials` | `None` | Pre-existing credentials. |
78+
| `creds_path` | `str` | `None` | Path to credentials file. |
79+
| `token_path` | `str` | `None` | Path to token file. |
80+
| `read` | `bool` | `True` | Enable read operations. |
81+
| `create` | `bool` | `False` | Enable create operations. |
82+
| `update` | `bool` | `False` | Enable update operations. |
83+
| `duplicate` | `bool` | `False` | Enable duplicate operations. |
84+
85+
## Toolkit Functions
86+
87+
| Function | Description |
88+
| ----------------------- | ----------------------------------------------- |
89+
| `read_sheet` | Read values from a Google Sheet |
90+
| `create_sheet` | Create a new Google Sheet |
91+
| `update_sheet` | Update data in a Google Sheet |
92+
| `create_duplicate_sheet`| Create a duplicate of an existing Google Sheet |
93+
94+
## Developer Resources
95+
96+
- View [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/googlesheets.py)
97+
- View [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/googlesheets_tools.py)

0 commit comments

Comments
 (0)