This example demonstrates how to use Composio tools that support file handling, such as sending emails with attachments using Gmail.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/composiohq/composio/llms.txt
Use this file to discover all available pages before exploring further.
Overview
In this example, you’ll learn how to:- Pass file paths to tools that support attachments
- Send emails with file attachments using Gmail
- Work with local file paths in tool arguments
Prerequisites
Complete Example
How It Works
Prepare File Path
Use Node’s
path module to construct the absolute path to your file. Composio handles reading and encoding the file.Tool Parameters
Absolute or relative file path to the attachment
Email address of the recipient
Email subject line
Email body content (plain text or HTML)
Gmail user ID (use ‘me’ for authenticated user)
Expected Output
Supported File Types
Composio automatically handles various file types based on the tool:Email Attachments (Gmail, Outlook)
Email Attachments (Gmail, Outlook)
- Images:
.png,.jpg,.jpeg,.gif,.bmp - Documents:
.pdf,.doc,.docx,.txt - Spreadsheets:
.xls,.xlsx,.csv - Presentations:
.ppt,.pptx - Archives:
.zip,.tar,.gz
File Upload Tools (Drive, Dropbox)
File Upload Tools (Drive, Dropbox)
All file types are supported. The tool will preserve the original file format and metadata.
Image Processing Tools
Image Processing Tools
Specific image formats depending on the tool (typically
.png, .jpg, .jpeg, .webp)Multiple Attachments
Some tools support multiple attachments. Check the tool schema:URL-Based File Handling
You can also pass URLs for some tools:Error Handling
Best Practices
Use Absolute Paths: Always use absolute paths or resolve relative paths using
path.join() or path.resolve()Check File Size: Be aware of size limits for different services (e.g., Gmail has a 25MB limit)
Validate File Exists: Check if the file exists before attempting to send it
Handle Errors: Always wrap file operations in try-catch blocks to handle missing files or permission errors
Next Steps
Custom Tools
Create custom tools with file handling
OpenAI Example
Combine file handling with AI agents