Mechanic provides powerful integration with Google Drive and Google Sheets, allowing you to automate file management and spreadsheet operations.
{% hint style="info" %} You can connect more than one Google account choosing which account to use when writing your task code. {% endhint %}
Before using Google integrations connect your Google accounts:
- Go to your Mechanic Settings screen
- Click on Authentication
- Connect your Google account
- Grant the necessary permissions when prompted
The Google Drive action allows you to upload and manage files in Google Drive.
See in-depth documentation of the Google Drive action here.
{% raw %}
{% action "google_drive" %}
{
"account": "your.email@example.com",
"uploads": {
"overwrite": true,
"simple.txt": "Hello, world!",
"report.pdf": {
"pdf": {
"html": "<h1>Report</h1><p>Content here</p>"
}
}
}
}
{% endaction %}
{% endraw %}
- Upload multiple files in a single action
- Paths can include folders (e.g., 'reports/monthly/file.txt')
- Overwrite existing files (optional)
- Generate various file types (text, PDF, CSV, HTML)
The Google Sheets action enables interaction with spreadsheets, including creation and data manipulation. \
See in-depth documentation of the Google Sheets action here.
{% raw %}
{% action "google_sheets" %}
{
"account": "your.email@example.com",
"operation": "append_rows",
"spreadsheet_id": "your-spreadsheet-id",
"sheet_name": "Sheet1",
"rows": [
["Column1", "Column2", "Column3"],
["Value1", "Value2", "Value3"]
]
}
{% endaction %}
{% endraw %}
create_spreadsheet
: Create new spreadsheetsappend_rows
: Add data to existing spreadsheetsexport_spreadsheet
: Export spreadsheets in various formats
- Text files
- PDFs (generated from HTML)
- CSV files
- HTML files
- Any binary file format
- XLSX (Excel)
- CSV
- HTML
- ODS
- TSV
The integration requires the https://www.googleapis.com/auth/drive.file
scope, which allows:
- Access to files created by the app
- Access to files explicitly shared with the app
- No access to other files in your Google Drive