Skip to main content

Overview

Enable your agents to upload, download, and manage files and folders in Microsoft OneDrive. Automate file operations, organize content, create sharing links, and streamline your cloud storage workflows with AI-powered automation.

Prerequisites

Before using the Microsoft OneDrive integration, ensure you have:
  • A CrewAI AMP account with an active subscription
  • A Microsoft account with OneDrive access
  • Connected your Microsoft account through the Integrations page

Setting Up Microsoft OneDrive Integration

1. Connect Your Microsoft Account

  1. Navigate to CrewAI AMP Integrations
  2. Find Microsoft OneDrive in the Authentication Integrations section
  3. Click Connect and complete the OAuth flow
  4. Grant the necessary permissions for file access
  5. Copy your Enterprise Token from Integration Settings

2. Install Required Package

3. Environment Variable Setup

To use integrations with Agent(apps=[]), you must set the CREWAI_PLATFORM_INTEGRATION_TOKEN environment variable with your Enterprise Token.
Or add it to your .env file:

Available Actions

Description: List files and folders in OneDrive.Parameters:
  • top (integer, optional): Number of items to retrieve (max 1000). Default is 50.
  • orderby (string, optional): Order by field (e.g., “name asc”, “lastModifiedDateTime desc”). Default is “name asc”.
  • filter (string, optional): OData filter expression.
Description: Get information about a specific file or folder.Parameters:
  • item_id (string, required): The ID of the file or folder.
Description: Download a file from OneDrive.Parameters:
  • item_id (string, required): The ID of the file to download.
Description: Upload a file to OneDrive.Parameters:
  • file_name (string, required): Name of the file to upload.
  • content (string, required): Base64 encoded file content.
Description: Create a new folder in OneDrive.Parameters:
  • folder_name (string, required): Name of the folder to create.
Description: Delete a file or folder from OneDrive.Parameters:
  • item_id (string, required): The ID of the file or folder to delete.
Description: Copy a file or folder in OneDrive.Parameters:
  • item_id (string, required): The ID of the file or folder to copy.
  • parent_id (string, optional): The ID of the destination folder (optional, defaults to root).
  • new_name (string, optional): New name for the copied item (optional).
Description: Move a file or folder in OneDrive.Parameters:
  • item_id (string, required): The ID of the file or folder to move.
  • parent_id (string, required): The ID of the destination folder.
  • new_name (string, optional): New name for the item (optional).
Description: Search for files and folders in OneDrive.Parameters:
  • query (string, required): Search query string.
  • top (integer, optional): Number of results to return (max 1000). Default is 50.
Description: Create a sharing link for a file or folder.Parameters:
  • item_id (string, required): The ID of the file or folder to share.
  • type (string, optional): Type of sharing link. Enum: view, edit, embed. Default is view.
  • scope (string, optional): Scope of the sharing link. Enum: anonymous, organization. Default is anonymous.
Description: Get thumbnails for a file.Parameters:
  • item_id (string, required): The ID of the file.
Description: List files and folders in a specific OneDrive path.Parameters:
  • folder_path (string, required): The folder path (e.g., ‘Documents/Reports’).
  • top (integer, optional): Number of items to retrieve (max 1000). Default is 50.
  • orderby (string, optional): Order by field (e.g., “name asc”, “lastModifiedDateTime desc”). Default is “name asc”.
Description: Get recently accessed files from OneDrive.Parameters:
  • top (integer, optional): Number of items to retrieve (max 200). Default is 25.
Description: Get files and folders shared with the user.Parameters:
  • top (integer, optional): Number of items to retrieve (max 200). Default is 50.
  • orderby (string, optional): Order by field. Default is “name asc”.
Description: Get information about a specific file or folder by path.Parameters:
  • file_path (string, required): The file or folder path (e.g., ‘Documents/report.docx’).
Description: Download a file from OneDrive by its path.Parameters:
  • file_path (string, required): The file path (e.g., ‘Documents/report.docx’).

Usage Examples

Basic Microsoft OneDrive Agent Setup

File Upload and Management

File Organization and Sharing

Troubleshooting

Common Issues

Authentication Errors
  • Ensure your Microsoft account has the necessary permissions for file access (e.g., Files.Read, Files.ReadWrite).
  • Verify that the OAuth connection includes all required scopes.
File Upload Issues
  • Ensure file_name and content are provided for file uploads.
  • Content must be Base64 encoded for binary files.
  • Check that you have write permissions to OneDrive.
File/Folder ID Issues
  • Double-check item IDs for correctness when accessing specific files or folders.
  • Item IDs are returned by other operations like list_files or search_files.
  • Ensure the referenced items exist and are accessible.
Search and Filter Operations
  • Use appropriate search terms for search_files operations.
  • For filter parameters, use proper OData syntax.
File Operations (Copy/Move)
  • For move_item, ensure both item_id and parent_id are provided.
  • For copy_item, only item_id is required; parent_id defaults to root if not specified.
  • Verify that destination folders exist and are accessible.
Sharing Link Creation
  • Ensure the item exists before creating sharing links.
  • Choose appropriate type and scope based on your sharing requirements.
  • anonymous scope allows access without sign-in; organization requires organizational account.

Getting Help

Need Help?

Contact our support team for assistance with Microsoft OneDrive integration setup or troubleshooting.