# Microsoft OneDrive

Connect your Microsoft OneDrive to automatically sync documents, spreadsheets, presentations, and other files into your Twig AI knowledge base.

## Overview

| Property            | Details                            |
| ------------------- | ---------------------------------- |
| **Type**            | Dynamic                            |
| **Refresh**         | Scheduled (Daily, Weekly, Monthly) |
| **Tier**            | 2 (Professional & Enterprise)      |
| **Authentication**  | OAuth 2.0 (Microsoft)              |
| **Supported Files** | Office documents, PDFs, and more   |

## When to Use OneDrive Connector

The OneDrive connector is ideal for:

* **Microsoft 365 Environments** - Organizations using Microsoft ecosystem
* **Personal Cloud Storage** - Individual OneDrive accounts
* **Office Documents** - Word, Excel, PowerPoint files
* **Cross-Platform Teams** - Mixed environment teams
* **Cloud-Native Workflows** - OneDrive-first organizations

## Supported File Types

### Microsoft Office Files

* **Word** (.doc, .docx) - Microsoft Word documents
* **Excel** (.xls, .xlsx, .xlsm) - Microsoft Excel spreadsheets
* **PowerPoint** (.ppt, .pptx) - Microsoft PowerPoint presentations
* **OneNote** (.one) - OneNote notebooks (limited support)

### Other Formats

* **PDF** (.pdf) - Portable Document Format
* **Text** (.txt) - Plain text files
* **Rich Text** (.rtf) - Rich Text Format
* **Images** (.jpg, .png, .gif) - Image files with text extraction
* **OpenDocument** (.odt, .ods, .odp) - Open Document formats

## Prerequisites

Before setting up:

* Microsoft account (personal or work/school)
* OneDrive access with files to sync
* Admin approval (for work/school accounts in some organizations)

## How to Set Up OneDrive Connector

### Step 1: Navigate to Data Sources

1. Log in to your Twig AI account
2. Click **Data** in the main navigation menu
3. Click **Add Data Source** or the **+** button
4. Choose **MS-OneDrive** from the list of connectors
5. Note: Available on Professional and Enterprise plans

### Step 2: Configure Basic Information

* **Name** (required): Descriptive name
  * Example: "Personal OneDrive", "Team Documents", "Product Files"
* **Description** (optional): Additional context
  * Example: "Marketing team's shared OneDrive folder"
* **Tags** (optional): Organization tags
  * Examples: "onedrive", "microsoft", "documents"

### Step 3: Authenticate with Microsoft

1. Click **Connect OneDrive** or **Authorize**
2. You'll be redirected to Microsoft's login page
3. Sign in with your Microsoft account:
   * **Personal**: <name@outlook.com>, <name@hotmail.com>
   * **Work/School**: <name@company.com>
4. Review requested permissions:
   * **Read files** - Access to your OneDrive files
   * **Read file metadata** - File names, dates, sizes
5. Click **Accept** to grant permissions
6. You may need admin approval for organizational accounts
7. You'll be redirected back to Twig AI

### Step 4: Select Folder or Files

After authentication, configure what to sync:

**Option 1: Entire OneDrive**

```json
{
  "path": "/",
  "recursive": true
}
```

**Option 2: Specific Folder**

```json
{
  "path": "/Documents/Product Docs",
  "recursive": true
}
```

**Option 3: Multiple Folders** Create separate data sources for each folder.

### Step 5: Configure Sync Options (JSON Parameters)

```json
{
  "path": "/Documents",
  "recursive": true,
  "fileTypes": ["docx", "xlsx", "pdf"],
  "includeShared": true,
  "maxFiles": 500,
  "modifiedAfter": "2024-01-01"
}
```

**Available Parameters:**

| Parameter       | Type    | Description                                 | Default    |
| --------------- | ------- | ------------------------------------------- | ---------- |
| `path`          | String  | Folder path to sync                         | "/" (root) |
| `recursive`     | Boolean | Include subfolders                          | true       |
| `fileTypes`     | Array   | File extensions to include                  | All        |
| `includeShared` | Boolean | Include files shared with you               | true       |
| `maxFiles`      | Number  | Maximum files to sync                       | 1000       |
| `modifiedAfter` | String  | Only files modified after date (YYYY-MM-DD) | All        |
| `maxDepth`      | Number  | Maximum folder depth                        | Unlimited  |

### Step 6: Test Connection

1. Click **Test Config** or **Test Connection**
2. Twig will verify:
   * Authentication is valid
   * Folder path is accessible
   * Permissions are sufficient
3. Wait for "Connection Successful" message

### Step 7: Set Refresh Schedule

Choose sync frequency:

* **Never** - Manual sync only
* **Daily** - Sync changes daily (recommended)
* **Weekly** - Sync weekly
* **Monthly** - Sync monthly

### Step 8: Save and Sync

1. Click **Save** or **Create**
2. Initial sync begins
3. Monitor progress in data sources list
4. Check process logs for errors

## Finding OneDrive Folder Paths

OneDrive uses path-based addressing:

### Common Paths

```
/                          - Root of your OneDrive
/Documents                 - Documents folder
/Pictures                  - Pictures folder
/Shared                    - Files shared with you
/Company Shared Library    - Company-wide shared folder
```

### Finding Specific Paths

1. Open OneDrive in your browser
2. Navigate to the desired folder
3. Look at the URL:

   ```
   https://onedrive.live.com/?id=ABC123&cid=XYZ789
   ```
4. Or use the folder name directly in path format:

   ```
   /Documents/Project Files
   ```

## Configuration Examples

### Example 1: Personal Documents

```
Name: Personal OneDrive Docs
Description: My personal documentation and notes
Authentication: OAuth (john@outlook.com)
Parameters:
{
  "path": "/Documents",
  "recursive": true,
  "fileTypes": ["docx", "pdf", "txt"],
  "maxFiles": 200
}
Refresh: Weekly
Tags: personal, onedrive, documents
```

### Example 2: Work Documents

```
Name: Work OneDrive
Description: Work-related files from company OneDrive
Authentication: OAuth (john@company.com)
Parameters:
{
  "path": "/",
  "recursive": true,
  "includeShared": true,
  "maxFiles": 500
}
Refresh: Daily
Tags: work, onedrive, company
```

### Example 3: Specific Project Folder

```
Name: Product Launch Files
Description: Product launch documentation and assets
Authentication: OAuth (pm@company.com)
Parameters:
{
  "path": "/Projects/Product Launch 2024",
  "recursive": false,
  "fileTypes": ["docx", "xlsx", "pptx"],
  "maxFiles": 100
}
Refresh: Daily
Tags: product, launch, onedrive
```

## Best Practices

### 1. Use Work/School Accounts for Teams

For organizational use:

* Use work/school Microsoft 365 accounts
* Leverage shared folders and team libraries
* Set up dedicated service accounts for integrations
* Ensure proper permissions across teams

### 2. Organize with Clear Folder Structure

Structure OneDrive for easy syncing:

```
📁 OneDrive/
  📁 Team Documentation/
    📄 Product Spec.docx
    📄 Technical Guide.docx
  📁 Support Materials/
    📄 FAQ.docx
    📄 Troubleshooting.pdf
  📁 Training/
    📄 Onboarding Guide.docx
```

### 3. Filter by File Type

Focus on document types that work well with AI:

```json
{
  "fileTypes": ["docx", "pdf", "txt", "xlsx"]
}
```

Avoid:

* Executables (.exe, .msi)
* Archives (.zip, .rar) - extract first
* Binary formats without text content

### 4. Set Appropriate Scope

**Good (Focused):**

```json
{
  "path": "/Documentation/Product",
  "recursive": true,
  "maxFiles": 200
}
```

**Avoid (Too Broad):**

```json
{
  "path": "/",
  "recursive": true
}
// May include personal files, photos, etc.
```

### 5. Handle Large File Collections

For many files:

* Set `maxFiles` limit
* Use `modifiedAfter` for recent files
* Split into multiple data sources by folder
* Set appropriate `maxDepth`

### 6. Monitor Shared Files

If using `includeShared: true`:

* Be aware of files shared from outside your organization
* Review permissions and access levels
* Consider security implications
* May want separate data source for shared files

## Understanding Sync Behavior

### Initial Sync

* Downloads all files in specified path
* Processes files in batches
* May take time for large collections

### Incremental Syncs

* Detects modified files since last sync
* Syncs only new or changed files
* Much faster than initial sync

### What Gets Synced

✅ **Synced:**

* New files added to folder
* Modified file content
* Files moved into synced path
* Renamed files (as new files)

❌ **Not Synced:**

* Files moved out (remain until cleanup)
* Deleted files (remain until cleanup)
* Files without read permission
* Files in recycle bin
* Zero-byte files

### File Conversion

Office files are processed directly:

* **Word** → Text extraction from .docx
* **Excel** → Data from cells and sheets
* **PowerPoint** → Text from slides
* **PDF** → Text extraction

## Permissions & Security

### OAuth Permissions Required

Twig requests:

* `Files.Read` - Read files in OneDrive
* `Files.Read.All` - Read all files accessible to user
* `offline_access` - Maintain connection for syncs

**Twig cannot:**

* Modify files
* Delete files
* Share files
* Upload files

### Data Security

* Files are encrypted in transit and at rest
* OAuth tokens are securely stored
* Original files remain in OneDrive
* You control access via Microsoft settings

### Organizational Policies

Work/school accounts may have:

* Admin approval requirements
* Third-party app restrictions
* Data Loss Prevention (DLP) policies
* Conditional access policies

**If blocked:** Contact your IT administrator to approve Twig AI.

### Revoking Access

To disconnect:

1. In Twig: Delete the data source
2. In Microsoft: Visit [Microsoft Account Apps](https://account.microsoft.com/privacy/app-access)
3. Find "Twig AI" and remove access

## Troubleshooting

### Authentication Failed

**Problem:** Can't connect OneDrive

**Solutions:**

* Verify correct Microsoft account
* Check if organizational admin approval needed
* Try clearing browser cache/cookies
* Ensure OneDrive is accessible
* Check if account is locked or suspended

### Admin Approval Required

**Problem:** "Admin approval required" error

**Solutions:**

* Contact IT administrator
* Request approval for Twig AI application
* Provide app details: Microsoft Graph API permissions
* May need Global Admin to grant consent
* Alternative: Use personal OneDrive account

### No Files Found

**Problem:** Sync completes but no files imported

**Solutions:**

* Verify path is correct (case-sensitive)
* Check authenticated account has access
* Ensure folder contains supported file types
* Review `fileTypes` filter in parameters
* Check `maxFiles` limit

### Permission Denied

**Problem:** Some files fail to import

**Solutions:**

* Verify access to all files in folder
* Check for encrypted files (may not be accessible)
* Review DLP policies blocking access
* Ensure files aren't in process of being uploaded
* Check for corrupted files

### Slow Syncs

**Problem:** Syncs take very long

**Solutions:**

* Reduce scope with more specific `path`
* Lower `maxFiles` limit
* Set `recursive: false` if deep folders not needed
* Filter by `fileTypes`
* Check OneDrive API rate limits

### Missing Recent Updates

**Problem:** Recent changes not appearing

**Solutions:**

* Verify OneDrive sync completed (green checkmark)
* Check last Twig sync date
* Manually trigger refresh
* Review process logs for errors
* Ensure file saved properly in OneDrive

## Advanced Configuration

### Syncing Multiple Folders

Create separate data sources:

```json
// Source 1: Documentation
{
  "path": "/Documentation",
  "fileTypes": ["docx", "pdf"]
}

// Source 2: Spreadsheets
{
  "path": "/Data",
  "fileTypes": ["xlsx"]
}
```

### Date-Based Filtering

Recent files only:

```json
{
  "modifiedAfter": "2024-01-01",
  "maxFiles": 300
}
```

### Limiting Folder Depth

Avoid deeply nested folders:

```json
{
  "path": "/Projects",
  "recursive": true,
  "maxDepth": 2
}
```

## OneDrive vs SharePoint

**Use OneDrive when:**

* Syncing personal or individual files
* Small team collaboration
* Personal Microsoft accounts
* Simple folder structures

**Use** [**SharePoint**](/product/data-integrations/ms-sharepoint.md) **when:**

* Enterprise document management
* Department-wide knowledge bases
* Complex permissions and workflows
* SharePoint-specific features (lists, libraries)

## Monitoring & Maintenance

### Regular Checks

**Weekly:**

* Verify last sync completed
* Check file count trends
* Review error logs

**Monthly:**

* Audit synced folders
* Update folder paths if structure changed
* Remove outdated data sources

### Metrics to Track

* **Files Synced:** Total file count
* **Last Sync Date:** When sync last ran
* **Sync Duration:** Processing time
* **Error Count:** Failed imports
* **Storage Used:** Indexed data size

## Next Steps

After connecting OneDrive:

1. [Test with document-based questions](/getting-started/ask-a-question.md)
2. [Create team-specific AI agents](/product/overview/add-an-ai-agent-persona.md)
3. [Monitor document usage](/product/monitoring/view-analytics.md)
4. Optimize folder structure
5. Expand to additional folders

## Related Connectors

* [Google Drive](/product/data-integrations/google-drive.md) - Google cloud storage
* [SharePoint](/product/data-integrations/ms-sharepoint.md) - SharePoint sites and libraries
* [Confluence](/product/data-integrations/confluence.md) - Wiki knowledge bases
* [Files](/product/data-integrations/files.md) - Direct file uploads
* [Slack](broken://pages/ZqCVeDsUAq2s0edspK89) - Team communications

## Support

For Microsoft/OneDrive issues:

* Microsoft Graph API: <https://docs.microsoft.com/graph>
* OneDrive Support: <https://support.microsoft.com/onedrive>
* Microsoft 365 Admin Center: <https://admin.microsoft.com>

For Twig integration:

* Check process logs for specific errors
* Contact Twig support with error details
* Provide folder paths and file types for troubleshooting


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.twig.so/product/data-integrations/ms-onedrive.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
