- Direct integration through specialized plugins for reading and writing data in spreadsheets.
- Automated cloud-based file management allowing the search, creation, and download of documents.
- Flexible configuration via JSON service accounts or OAuth 2.0 authentication protocols.
- Bidirectional synchronization that allows you to convert Google Workspace documents to compatible formats such as XLSX and PDF.
If you want your AI agents to work with real and up-to-date information, connect Dify with Google Sheets It's one of the simplest ways to achieve this. The spreadsheet can act as a small data repository from which to query products, customers, tasks, or any other record used by your application.
This integration allows a Dify workflow to read different ranges and write new values without requiring manual data copying. For example, you can create a wizard that checks order status, categorizes form responses, or updates a table after processing a request.
There are several ways to do this. The most direct route uses a Google Sheets plugin and a Google Cloud service accountIf you need to react automatically to changes, run scheduled tasks, or combine the spreadsheet with other applications, you can also use an intermediary platform like n8n.
What you need to connect Dify with Google Sheets

Before we begin, it's worth clarifying that the add-on omluc/google_sheets Available in the Dify Marketplace, this is a community plugin. It is not part of the official plugins developed by the Dify team, although it can be installed from their extensions marketplace.
This plugin currently incorporates two main tools:
- Batch Get: retrieves data from one or more ranges in a spreadsheet.
- Batch Update: updates multiple ranges within the same operation.
These functions can be added as tools within a workflow or made available to an agent for use as needed. To configure them, you will need:
- A Google account with access to Google Cloud.
- Un project created on Google Cloud.
- La Google Sheets API enabled.
- A service account with a key in JSON format.
- A shared sheet with the email address of that account.
The service account functions as a separate identity. Therefore, Dify does not directly use your personal Google account, nor can it automatically access all your spreadsheets. It will only have access to the documents you explicitly share with it.
How to create a service account on Google Cloud
The first step is to go to the Google Cloud Console and create a new project or select an existing one. Within the project, open the APIs and Services section, go to the library, and search for... Google Sheets APIThen, tap the option to enable it.
Next, enter IAM and administration > Service accounts and create a new account. You can give it a name that makes it easy to identify what it's used for, such as "Dify Google Sheets".
During this process, Google may offer you the option to assign roles within the project. For this integration, you don't need to assign a general owner or editor role for the entire project. Access to specific sheets is controlled later through the Google Sheets sharing options.
Once the account has been created:
- Open your details from the service accounts section.
- Go to the tab Keys.
- Click on Add key > Create a new key.
- Select the format JSON.
- Download and save the file in a safe place.
The JSON file contains sensitive information, including a private key. You must not publish it, send it via email, or upload it to a repository. Anyone who obtains that key could act with the service account's permissions.
How to install and configure the plugin in Dify

In Dify, open the Plugin Marketplace and search for the Google Sheets add-on published by omlucCheck the author's name before installing it to avoid confusing it with other extensions that may offer different functions.
After installation, open the plugin's credentials settings. The form will request the service account key. Open the downloaded JSON file with a text editor. copy all its content and paste it in the corresponding field.
Do not copy only the email, project ID, or private key separately. The add-on requires the complete JSON structure to authenticate requests made to Google Sheets.
Next, save the credentials and open the spreadsheet you want to use. Inside the JSON file, you'll find a field called client_email, whose value will have an appearance similar to this:
[email protected]
Click on Share within Google Sheets and add that address as if it were another user:
- Grants permission to reader if Dify will only consult data.
- Grants permission to editor if you also need to update cells.
Sharing the spreadsheet publicly via a link is not recommended. The service account allows you to keep the document private and restrict access to a specific user.
How to read data from Google Sheets from a workflow
To retrieve information from the sheet, add a tool node to the Dify workflow and select the action Batch GetThe add-in allows you to query multiple ranges in a single operation, avoiding the need to create a different node for each section of the table.
You will need to provide the spreadsheet identifier. This appears in its web address, between /d/ y /editIn a URL with this structure:
https://docs.google.com/spreadsheets/d/IDENTIFICADOR/edit
You must only use the value marked as IDENTIFICADOR.
You will also need to specify the tab name and range using Google Sheets notation. Some examples would be:
Clientes!A2:D50
Productos!A:C
Pedidos!B2:B20
The name before the exclamation mark corresponds to the tab. The letters and numbers that follow delimit the columns and rows to be retrieved.
You can then pass the result to an LLM node to summarize it, locate a record, or prepare a response. It's advisable to instruct the model to use only the retrieved data and to clearly indicate when it doesn't find a match, especially if the sheet contains customer, inventory, or order information.
How to update cells from Dify

The tool Batch Update It allows you to write values in various ranges. This can be used, for example, to change the status of a task, save an AI-generated classification, or add the result of a request.
Before using it, verify that the service account has editor permissions on the document. If it only has read permissions, queries will work, but Google will reject attempts to write.
It is also advisable to prevent the model from freely choosing any range or value. A more secure configuration consists of First validate the data, limit the modifiable columns, and build the range using controlled variables. through the workflow.
For example, you can organize the process like this:
- El user enters an order number.
- Batch Get gets back in line corresponding.
- A conditional node check if the order exists.
- The model analyzes or classifies the information.
- Batch Update writes the result in a specific column.
- The output node confirms which record has been modified.
Whenever possible, use a test spreadsheet during setup. A poorly constructed update can overwrite existing information, especially when the range covers more rows or columns than intended.
Common mistakes when connecting Dify with Google Sheets
If you encounter an authentication error, verify that you have pasted the complete JSON file and that its format has not been altered. Private keys contain line breaks that must be maintained within the document structure.
When Dify indicates that it cannot find or access the sheet, check these points:
- The Google Sheets API is enabled in the correct project.
- The sheet has been shared with the exact value of
client_email. - The sheet identifier does not contain any additional parts of the URL.
- The tab name matches, including capitalization, spaces, and accents.
- The range uses a valid notation, such as
Datos!A2:C20. - The account has editor permission if the workflow attempts to write.
If you've deleted or deactivated the key in Google Cloud, you'll need to create a new one and replace the credentials saved in Dify. You should also generate a new key if you suspect the JSON file has been exposed.
Differences between the Google Sheets and Google Drive plugins
Google Sheets and Google Drive should not be treated as a single integration. The Sheets community plugin is intended for view and modify cell ranges through a service account.
In contrast, the official Google Drive plugin available as a data source uses OAuth 2.0It allows you to browse folders, list files, and download their contents for processing or incorporation into a Dify knowledge stream.
The Drive connector is read-only: it doesn't create files, organize folders, or modify or delete documents. When you download native files from Google Workspace, it automatically exports them to compatible formats. Google Sheets are converted to XLSX files, while Google Docs and Google Slides are exported as PDFs.
Therefore, you must choose the integration according to the task:
- Use the plugin for Google Sheets to read or write values in cells.
- Use the data source of Google Drive to locate and download files.
- Combine both only if the workflow needs to work with cells and entire documents.
How to extend integration using n8n

The Google Sheets add-on is useful for perform actions from DifyHowever, it doesn't cover all automation scenarios on its own. If you need triggers, scheduled executions, or connections to multiple applications, you can place n8n as intermediary.
In this architecture, Dify can send the data to an n8n webhook via an HTTP request. n8n receives the request, It executes its Google Sheets nodes and returns the result to the workflow.
You can also reverse the process. For example, n8n can detect a new row, process its values, and call the API of an application published on Dify. The AI-generated result can then be written to another column in the same sheet.
This system allows you to create automations such as:
- Automatically classify the answers added to a sheet.
- Generate summaries at a specific time.
- Update records and send a notification at the same time.
- Combine data from Google Sheets with email, CRM, or other applications.
- Apply validations before allowing AI to modify a cell.
In return, the configuration is more complex and requires protecting the webhooks, credentials, and API keys used by both services.
Connecting Dify to Google Sheets allows you to transform a standard spreadsheet into an easily accessible information source for agents or workflows. The most direct approach is to enable the Sheets API, create a service account, install the plugin, and share only the necessary sheets with your email address.
From there, Batch Get allows you to query ranges, and Batch Update writes results.If the project needs to work with complete documents, react to events, or coordinate multiple applications, you can complement this setup with Google Drive or n8n without confusing the functions of each tool.
I am a technology enthusiast who has turned his "geek" interests into a profession. I have spent more than 10 years of my life using cutting-edge technology and tinkering with all kinds of programs out of pure curiosity. Now I have specialized in computer technology and video games. This is because for more than 5 years I have been writing for various websites on technology and video games, creating articles that seek to give you the information you need in a language that is understandable to everyone.
If you have any questions, my knowledge ranges from everything related to the Windows operating system as well as Android for mobile phones. And my commitment is to you, I am always willing to spend a few minutes and help you resolve any questions you may have in this internet world.
