How to Automate Asana File Attachments to Google Drive Using n8n

admin1234 Avatar

Introduction

Asana is a popular project management tool used by many startup teams and engineering groups to track tasks and collaborate efficiently. One widely used feature in Asana is attaching files directly to tasks to keep relevant documents handy. However, storing files inside Asana can increase subscription costs as the attached file storage grows or create difficulties managing large files.

This guide explains how to automate the process of saving all Asana task file attachments to Google Drive automatically using n8n—a free and open-source workflow automation tool. By offloading attachment storage from Asana to a centralized Google Drive folder and automatically linking back, you reduce Asana storage usage and save on costs. Automation engineers, startup CTOs, and ops teams will benefit by streamlining file management while maintaining easy access to attachments.

Use Case and Benefits

Problem: Asana’s built-in file attachment storage can become costly or cumbersome when storing many or large files directly in tasks.

Who benefits:
– Project managers wanting centralized and scalable file storage
– Automation engineers looking to reduce license or storage fees
– Startup teams seeking seamless workflows integrating Asana and Google Drive

Key result:
– Automatically upload files attached to tasks into a designated Google Drive folder
– Replace Asana attachments with Google Drive shareable links inside the task comments or custom fields
– Centralized file repository with fine-grained access and scalability

Tools and Services Integrated

– Asana API (to monitor tasks and fetch attachments)
– Google Drive API (to upload and manage files)
– n8n automation platform (to orchestrate the workflow)

Setup Overview

Trigger: Periodic check (via Cron node) or webhook for Asana tasks updates
Process:
1. Fetch tasks from Asana
2. Identify new file attachments
3. Download attachments from Asana
4. Upload files to Google Drive
5. Update Asana task with Google Drive link

Technical Tutorial

Prerequisites:
– n8n installed (self-hosted or cloud)
– Asana developer app/token with scopes to read tasks and attachments
– Google service account or OAuth credentials to access Google Drive

Step 1: Create a new workflow in n8n

Start with a blank workflow in n8n.

Step 2: Set up the Trigger (Cron or Webhook)

Option 1: Cron Trigger
– Add a Cron node to run every hour or as frequent as needed.

Option 2: Webhook Trigger
– Use Asana’s webhook to notify on task changes (requires public URL).

For simplicity, we’ll proceed with a Cron node.

Step 3: Use Asana Node – Get Tasks

– Add an ‘HTTP Request’ node or n8n Asana integration node (if available).
– Configure to call GET /tasks endpoint to fetch tasks in the project.
– Parameters: project ID, opt_fields=attachments

This fetches tasks with their attachments metadata.

Step 4: Filter Tasks with New Attachments

– Use a ‘Function’ node to filter out tasks that have attachments, and compare with previously processed files to avoid duplicates.
– Store processed file IDs in n8n’s internal storage or an external database.

Step 5: Download Attachments from Asana

– Use HTTP Request node to download each attachment file.
– You can fetch the download URL from attachment metadata.
– Important to include Asana access token in the authorization header.

Step 6: Upload Files to Google Drive

– Add a Google Drive node configured with appropriate credentials.
– Use the ‘Upload File’ operation.
– Set destination folder where files should be stored.
– Use the file data downloaded from Asana.

Step 7: Update Asana Task with Google Drive Link

– Use HTTP Request node to add a comment or update a custom field with the Google Drive shareable link.
– Alternatively, remove the original attachment if desired.
– The POST /tasks/{task_gid}/stories endpoint creates a comment on the task.

Step 8: Save Processed File IDs

– Record IDs of successfully processed attachments to prevent reprocessing.
– Use n8n’s Memory or External DB nodes.

Detailed Node Breakdown

1. Cron Trigger
– Runs workflow systematically ensuring regular sync.

2. Asana HTTP Request (GET tasks)
– Method: GET
– URL: https://app.asana.com/api/1.0/projects/{project_gid}/tasks?opt_fields=attachments
– Headers: Authorization: Bearer {asana_token}

3. Function Filter
– Checks if tasks have new attachments by comparing with stored IDs.

4. HTTP Request (Download attachment)
– GET {attachment.download_url}
– Headers: Authorization: Bearer {asana_token}

5. Google Drive Upload Node
– Operation: Upload
– Destination Folder ID: {drive_folder_id}
– File data: binary data from HTTP download

6. HTTP Request (Update Asana Task)
– POST https://app.asana.com/api/1.0/tasks/{task_gid}/stories
– Body: {text: ‘Attachment moved to Google Drive: {file_link}’}

7. Function/Set Node
– Store processed file ID for deduplication

Common Pitfalls and Tips

– Asana API rate limits: Implement error handling and retry with exponential backoff.
– File size limits: Verify Google Drive upload limits; large files should be chunked.
– Authentication: Securely store API tokens and use environment variables.
– Duplicate processing: Track processed files reliably to avoid repeated uploads.
– Webhook setup: For near real-time sync, configure Asana webhooks but handle webhook expiration.

Scaling and Adaptation

– Add multiple project support by looping through project lists.
– Extend to sync other data fields or synchronize bi-directionally.
– Integrate Slack or email notifications upon uploads.
– Store metadata in external DB for reporting and auditing.

Summary

Automating the transfer of Asana file attachments to Google Drive using n8n allows teams to save on Asana storage costs and centralize file management in Google Drive. By following the outlined workflow: fetching tasks, downloading attachments, uploading to Drive, and linking back inside Asana tasks, automation engineers and startup teams can build robust, scalable integrations that maintain efficient project collaboration.

Bonus Tip

Implement OAuth token refresh mechanisms in your n8n credentials for Asana and Google Drive to avoid workflow failures due to token expiry. Additionally, enable error notifications in n8n to get alerted promptly if issues occur during the automation.

This approach unlocks greater control over files and seamless collaboration without additional SaaS costs.