# Microsoft SharePoint

Connect your Microsoft SharePoint sites to sync document libraries, lists, and pages into your Twig AI knowledge base for enterprise-wide knowledge management.

## Overview

| Property           | Details                            |
| ------------------ | ---------------------------------- |
| **Type**           | Dynamic                            |
| **Refresh**        | Scheduled (Daily, Weekly, Monthly) |
| **Tier**           | 2 (Professional & Enterprise)      |
| **Authentication** | OAuth 2.0 (Microsoft)              |
| **Content Types**  | Document libraries, pages, lists   |

## When to Use SharePoint Connector

The SharePoint connector is ideal for:

* **Enterprise Knowledge Management** - Department or company-wide content
* **Document Libraries** - Structured document repositories
* **Team Sites** - Collaborative team workspaces
* **Intranet Content** - Internal communication and resources
* **Compliance-Required Storage** - Regulated document management
* **Large-Scale Deployments** - Enterprise Microsoft 365 environments

## Supported Content Types

### Document Libraries

* Office documents (Word, Excel, PowerPoint)
* PDF files
* Text documents
* Images with text
* Templates and forms

### SharePoint Pages

* Modern pages and news
* Wiki pages
* Site pages
* Web parts content

### Lists (Limited)

* List items with text fields
* Metadata and descriptions
* Announcements

## Prerequisites

Before setting up:

* SharePoint Online (Microsoft 365)
* Site access (Member or Owner permissions)
* Organizational Microsoft account
* Admin approval for OAuth (if required)

## How to Set Up SharePoint Connector

### Step 1: Gather SharePoint Information

You'll need:

1. **Site URL** - Your SharePoint site address
2. **Document Library Name** - Name of library to sync (optional)
3. **Microsoft Account** - With access to the site

### Step 2: Find Your SharePoint Site URL

Your SharePoint URL follows this pattern:

```
https://[tenant].sharepoint.com/sites/[sitename]
        ^^^^^^^^                        ^^^^^^^^
        Your org                        Site name
```

**Examples:**

* `https://contoso.sharepoint.com/sites/engineering`
* `https://acmecorp.sharepoint.com/sites/hr`
* `https://company.sharepoint.com/sites/projectalpha`

**To find your site URL:**

1. Navigate to your SharePoint site
2. Copy the URL from your browser address bar
3. Use only up to `/sites/[sitename]` (don't include library or page paths)

### Step 3: 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-Sharepoint** from the list
5. Note: Available on Professional and Enterprise plans

### Step 4: Configure Basic Information

* **Name** (required): Descriptive name
  * Example: "Engineering Site", "HR Document Library", "Product Team Site"
* **Description** (optional): Additional context
  * Example: "Engineering team SharePoint with technical documentation"
* **Tags** (optional): Organization tags
  * Examples: "sharepoint", "engineering", "internal"

### Step 5: Authenticate with Microsoft

1. Click **Connect SharePoint** or **Authorize**
2. You'll be redirected to Microsoft login
3. Sign in with your organizational account (<name@company.com>)
4. Review requested permissions:
   * **Read SharePoint items** - Access to site content
   * **Read site collections** - Browse sites
   * **Read user profiles** - User information
5. Admin approval may be required
6. Click **Accept**
7. You'll be redirected back to Twig

### Step 6: Configure Site and Library

#### Site URL (Required)

```
https://company.sharepoint.com/sites/engineering
```

#### Parameters (JSON)

```json
{
  "siteUrl": "https://company.sharepoint.com/sites/engineering",
  "libraryName": "Documents",
  "includeFolders": ["/Shared Documents/Product Specs"],
  "excludeFolders": ["/Shared Documents/Archive"],
  "fileTypes": ["docx", "pdf", "xlsx"],
  "includePages": true,
  "recursive": true,
  "maxFiles": 1000
}
```

**Available Parameters:**

| Parameter        | Type    | Description                        | Default     |
| ---------------- | ------- | ---------------------------------- | ----------- |
| `siteUrl`        | String  | SharePoint site URL (required)     | -           |
| `libraryName`    | String  | Document library name              | "Documents" |
| `includeFolders` | Array   | Specific folders to sync           | All         |
| `excludeFolders` | Array   | Folders to skip                    | None        |
| `fileTypes`      | Array   | File extensions to include         | All         |
| `includePages`   | Boolean | Sync SharePoint pages              | true        |
| `includeLists`   | Boolean | Sync list items                    | false       |
| `recursive`      | Boolean | Include subfolders                 | true        |
| `maxFiles`       | Number  | Maximum files to sync              | 2000        |
| `modifiedAfter`  | String  | Only files after date (YYYY-MM-DD) | All         |

### Step 7: Test Connection

1. Click **Test Config** or **Test Connection**
2. Twig will verify:
   * Site URL is valid and accessible
   * Authentication has proper permissions
   * Library/folders can be accessed
3. Review test results
4. Fix any errors before proceeding

### Step 8: Set Refresh Schedule

Choose sync frequency:

* **Never** - Manual sync only
* **Daily** - Sync changes daily (recommended for active sites)
* **Weekly** - Sync weekly (standard for most sites)
* **Monthly** - Sync monthly (for stable content)

### Step 9: Save and Sync

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

## Finding SharePoint Library Names

### Default Libraries

Most SharePoint sites have these standard libraries:

* `Documents` - Default document library
* `Site Pages` - Modern pages
* `Site Assets` - Images and files
* `Shared Documents` - Shared files

### Finding Custom Library Names

**Method 1: From SharePoint UI**

1. Navigate to your SharePoint site
2. Click on the library in the left navigation
3. The library name appears in the page title and URL

**Method 2: From URL**

```
https://company.sharepoint.com/sites/engineering/ProductDocs
                                                   ^^^^^^^^^^^
                                                   Library name
```

**Method 3: Site Contents**

1. Go to **Site Contents** (gear icon → Site Contents)
2. All libraries are listed with their names

## Configuration Examples

### Example 1: Team Site Documents

```
Name: Engineering Team Documents
Description: Engineering team's document library
Authentication: OAuth (john@company.com)
Parameters:
{
  "siteUrl": "https://company.sharepoint.com/sites/engineering",
  "libraryName": "Documents",
  "recursive": true,
  "includePages": true,
  "fileTypes": ["docx", "pdf", "xlsx"]
}
Refresh: Daily
Tags: engineering, sharepoint, documents
```

### Example 2: Specific Folder Only

```
Name: Product Specifications
Description: Product spec documents from SharePoint
Authentication: OAuth (pm@company.com)
Parameters:
{
  "siteUrl": "https://company.sharepoint.com/sites/product",
  "libraryName": "Documents",
  "includeFolders": ["/Shared Documents/Specifications"],
  "recursive": false,
  "fileTypes": ["docx", "pdf"],
  "maxFiles": 200
}
Refresh: Weekly
Tags: product, specs, sharepoint
```

### Example 3: Multiple Libraries (Create Separate Sources)

```
// Source 1: Documentation Library
{
  "siteUrl": "https://company.sharepoint.com/sites/team",
  "libraryName": "Documentation",
  "recursive": true
}

// Source 2: Training Materials
{
  "siteUrl": "https://company.sharepoint.com/sites/team",
  "libraryName": "Training",
  "recursive": true
}
```

### Example 4: Pages and Documents

```
Name: Intranet Content
Description: Intranet pages and supporting documents
Authentication: OAuth (comms@company.com)
Parameters:
{
  "siteUrl": "https://company.sharepoint.com/sites/intranet",
  "includePages": true,
  "libraryName": "Documents",
  "recursive": true,
  "maxFiles": 500
}
Refresh: Daily
Tags: intranet, communications, sharepoint
```

## Best Practices

### 1. Start with Specific Libraries

Rather than syncing entire site:

```json
{
  "libraryName": "Technical Documentation",
  "recursive": true
}
```

### 2. Use Folder Filtering

Focus on relevant content:

```json
{
  "includeFolders": [
    "/Shared Documents/Public",
    "/Shared Documents/Training"
  ],
  "excludeFolders": [
    "/Shared Documents/Archive",
    "/Shared Documents/Personal"
  ]
}
```

### 3. Filter by File Type

Optimize for AI-readable content:

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

Avoid:

* Media files (unless needed)
* Executables
* Archives

### 4. Set Appropriate Scope

**Good (Focused):**

```json
{
  "libraryName": "Product Docs",
  "includeFolders": ["/Shared Documents/Current"],
  "maxFiles": 500
}
```

**Avoid (Too Broad):**

```json
{
  "recursive": true,
  "maxFiles": 10000
}
// May include irrelevant or personal files
```

### 5. Sync Multiple Sites Separately

Create individual data sources for different sites:

* Engineering Site
* HR Site
* Product Site
* Marketing Site

Better organization and easier management.

### 6. Consider Permissions

* Only sync libraries accessible to all team members
* Avoid syncing restricted/confidential content
* Create agents with appropriate access controls
* Review content before making available to AI

### 7. Handle Large Sites

For sites with many files:

* Set `maxFiles` limit
* Use `modifiedAfter` for recent content
* Sync specific folders only
* Create multiple focused data sources

## Understanding Sync Behavior

### Initial Sync

* Scans entire library/folders
* Downloads all matching files
* Processes SharePoint pages
* May take significant time for large libraries

### Incremental Syncs

* Detects files modified since last sync
* Syncs only new or changed content
* Much faster than initial sync
* Tracks file metadata for changes

### What Gets Synced

✅ **Synced:**

* New files added to library
* Modified file content
* Updated pages
* New pages
* Files moved into synced folders
* Renamed files (as new files)

❌ **Not Synced:**

* Deleted files (remain in Twig until cleanup)
* Files in recycle bin
* Files without read permission
* Checkout files (locked for editing)
* System files and folders

### Content Processing

**Documents:**

* Word, Excel, PowerPoint → Text extraction
* PDF → Text extraction
* HTML pages → Content extraction

**SharePoint Pages:**

* Modern pages → Full content
* Text web parts → Extracted text
* Links and references → Captured

**Lists:**

* List items → Title and text fields
* Metadata → Included if relevant

## Permissions & Security

### OAuth Permissions Required

Twig requests:

* `Sites.Read.All` - Read SharePoint sites and content
* `Files.Read.All` - Read files in document libraries
* `User.Read` - Read user profile information

**Twig cannot:**

* Modify files or pages
* Delete content
* Change permissions
* Share files
* Create new content

### SharePoint Permissions

The authenticated user must have:

* **Read** access to site
* **Read** access to document libraries
* Member or Visitor role on site

### Tenant-Level Considerations

* Admin may need to approve app
* Conditional Access policies may apply
* DLP policies may restrict content
* Information barriers may limit access

**If blocked:** Contact SharePoint/Microsoft 365 administrator.

### Revoking Access

To disconnect:

1. In Twig: Delete the data source
2. In Microsoft: [Microsoft Account Apps](https://account.microsoft.com/privacy/app-access)
3. In SharePoint: Site Settings → Site App Permissions
4. Remove "Twig AI" access

## Troubleshooting

### Site Not Found

**Problem:** Can't connect to SharePoint site

**Solutions:**

* Verify site URL is correct and complete
* Ensure site exists and is not deleted
* Check you have access to the site
* Try accessing site in browser first
* Verify tenant URL (might be .sharepoint.com vs .sharepoint.us)

### Authentication Failed

**Problem:** OAuth authentication fails

**Solutions:**

* Use organizational account (not personal)
* Ensure account has site access
* Check if admin approval is required
* Try re-authenticating
* Clear browser cache/cookies

### Library Not Found

**Problem:** Can't access specified library

**Solutions:**

* Verify library name is exact match (case-sensitive)
* Check library exists on the site
* Ensure you have read permission to library
* Try "Documents" (default library name)
* Look in Site Contents for library name

### No Files Synced

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

**Solutions:**

* Verify library contains supported file types
* Check `fileTypes` filter isn't too restrictive
* Review `includeFolders` paths
* Ensure files aren't checked out (locked)
* Look for permission issues in process logs

### Permission Denied Errors

**Problem:** Some files fail to sync

**Solutions:**

* Check file-level permissions
* Verify not in restricted folder
* Ensure files aren't checked out
* Review DLP policies
* Look for encrypted/IRM-protected files

### Slow Syncs

**Problem:** Syncs take very long time

**Solutions:**

* Reduce `maxFiles` limit
* Use more specific `includeFolders`
* Set `recursive: false` if appropriate
* Filter by `fileTypes`
* Split into multiple smaller data sources
* Check SharePoint throttling/performance

### Missing Recent Changes

**Problem:** Recent updates not appearing

**Solutions:**

* Check last sync date in Twig
* Verify file is checked in (not draft)
* Manually trigger refresh
* Review process logs for errors
* Ensure SharePoint sync completed

## Advanced Configuration

### Multi-Site Setup

Sync multiple SharePoint sites:

```
// Site 1: Engineering
{
  "siteUrl": "https://company.sharepoint.com/sites/engineering"
}

// Site 2: Product
{
  "siteUrl": "https://company.sharepoint.com/sites/product"
}

// Site 3: Marketing
{
  "siteUrl": "https://company.sharepoint.com/sites/marketing"
}
```

### Hub Site Architecture

For hub-associated sites:

* Sync each site separately
* Use consistent naming convention
* Tag with hub association
* Create hub-level AI agents

### Metadata Filtering

While not directly supported, you can:

1. Organize files by folder based on metadata
2. Use folder filtering to sync specific types
3. Leverage SharePoint views to identify content

### Content Type Filtering

Focus on specific SharePoint content types:

* Sync only document libraries (not lists)
* Include pages for intranet content
* Skip media libraries

## SharePoint vs OneDrive

**Use SharePoint when:**

* Enterprise-wide knowledge management
* Multiple team sites
* Complex permissions and workflows
* Department or company-level content
* Integration with other SharePoint features

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

* Personal or small team files
* Individual user documents
* Simpler file structures
* Personal Microsoft accounts

## Monitoring & Maintenance

### Regular Checks

**Weekly:**

* Verify last sync completed
* Check file count trends
* Review any error logs
* Ensure new content is syncing

**Monthly:**

* Audit synced libraries
* Update folder filters if structure changed
* Review permissions and access
* Check for outdated content

**Quarterly:**

* Assess AI usage of SharePoint content
* Optimize sync configuration
* Review and cleanup old data sources

### Metrics to Track

* **Files Synced:** Total document count
* **Pages Synced:** SharePoint pages indexed
* **Last Sync:** When sync last ran successfully
* **Sync Duration:** Processing time
* **Error Rate:** Percentage of failed imports
* **Storage Used:** Indexed data size

## Enterprise Best Practices

### 1. Governance

* Document which sites are synced
* Define naming conventions
* Establish refresh schedules
* Set retention policies
* Review access regularly

### 2. Security

* Use service accounts for production
* Implement least-privilege access
* Audit AI access to sensitive content
* Review compliance requirements
* Monitor for data leaks

### 3. Performance

* Limit sync scope appropriately
* Stagger refresh schedules across sources
* Monitor API throttling
* Use folder filters effectively
* Split large libraries

### 4. Change Management

* Communicate with site owners
* Document synced libraries
* Plan for SharePoint migrations
* Update configurations after restructures

## Next Steps

After connecting SharePoint:

1. [Test knowledge coverage](/getting-started/ask-a-question.md)
2. [Create department-specific agents](/product/overview/add-an-ai-agent-persona.md)
3. [Monitor content usage analytics](/product/monitoring/view-analytics.md)
4. Optimize folder structure and filters
5. Expand to additional sites

## Related Connectors

* [OneDrive](/product/data-integrations/ms-onedrive.md) - Individual file storage
* [Confluence](/product/data-integrations/confluence.md) - Alternative wiki platform
* [Google Drive](/product/data-integrations/google-drive.md) - Google cloud storage
* [Files](/product/data-integrations/files.md) - Direct file uploads
* [Website](/product/data-integrations/website.md) - Public SharePoint pages

## Support

For SharePoint/Microsoft issues:

* SharePoint Online: <https://docs.microsoft.com/sharepoint>
* Microsoft Graph API: <https://docs.microsoft.com/graph>
* Microsoft 365 Admin Center: <https://admin.microsoft.com>

For Twig integration:

* Check process logs for specific errors
* Contact Twig support with site URL and library details
* Provide permission details if access issues
* Share error messages 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-sharepoint.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.
