Smartgent SharePoint Trigger icon

Smartgent SharePoint Trigger

Monitor SharePoint folders for new files and changes

Overview

This node monitors a specified SharePoint folder for file changes and triggers workflows based on those events. It supports detecting when files are added, modified, or both added and modified within the monitored folder. The node can also recursively monitor subfolders and optionally download the content of triggered files as binary data.

Common scenarios where this node is beneficial include:

  • Automating document processing workflows when new files arrive in a SharePoint folder.
  • Keeping external systems synchronized by triggering updates when files change.
  • Archiving or backing up files automatically upon modification.
  • Monitoring specific file types by filtering with extensions.

For example, you could use this node to watch a "Contracts" folder and trigger a workflow that extracts metadata from newly added PDF contracts, or monitor a "Reports" folder and download updated Excel files for further analysis.

Properties

Name Meaning
Event The type of file event to trigger on:
• File Added — triggers when a new file is added.
• File Modified — triggers when an existing file is modified.
• File Added or Modified — triggers on either event.
Folder Path to Monitor The relative path to the SharePoint folder to monitor. Use "/" for the root Documents library or specify subfolders like "MyFolder/SubFolder". Paths are relative to the Documents library root.
Poll Interval How often (in seconds) the node checks for changes in the folder. Minimum 10 seconds, maximum 3600 seconds (1 hour).
Additional Options Collection of optional settings:
• File Extensions Filter: Comma-separated list of file extensions to monitor (e.g., pdf,docx,xlsx). Leave empty to monitor all files.
• Include Subfolders: Whether to monitor recursively.
• Download File Content: Whether to download the file content as binary data when triggered.

Output

The node outputs an array of items, each representing a detected file event matching the configured criteria. Each item contains:

  • json object with:

    • event: The event type ("fileAdded", "fileModified", or "fileAddedOrModified"), or "test" if running in test mode.
    • trigger: The node identifier string.
    • file: Metadata about the file including:
      • id: Unique file ID.
      • name: File name.
      • lastModifiedDateTime: Timestamp of last modification.
      • size: File size in bytes.
      • webUrl: URL to view the file in SharePoint.
      • downloadUrl: Direct download URL.
      • mimeType: MIME type of the file.
    • folder: Information about the monitored folder:
      • path: The folder path.
      • driveId: Drive identifier.
      • siteId: Site identifier.
    • timestamp: ISO timestamp of the trigger event.
    • If in test mode, additional fields like testMode, testNote, and testExecutionTime are included.
    • If downloading content fails, a downloadError message is included.
  • Optionally, if "Download File Content" is enabled, a binary property containing:

    • data: Base64-encoded file content.
    • mimeType: MIME type of the file.
    • fileName: File name.
    • fileSize: Size in bytes.

If no new or modified files are found during polling, the node returns null to indicate no trigger.

Dependencies

  • Requires valid credentials for accessing the Microsoft SharePoint API via OAuth2 client credentials flow.
  • Needs configuration of an API key credential with tenant ID, client ID, and client secret for authentication.
  • Uses Microsoft Graph API endpoints to:
    • Obtain access tokens.
    • Retrieve site and drive IDs.
    • List files and folders.
    • Download file contents.
  • The node polls SharePoint at the configured interval; ensure network connectivity and API permissions allow these operations.

Troubleshooting

  • No files triggering:
    Verify the folder path is correct and accessible. Use "/" to test the root folder. Check that files exist and match any extension filters. Confirm your credentials have permission to access the folder.

  • Authentication errors:
    Common error messages include "Authentication failed" or "Invalid client credentials." Ensure the tenant ID, client ID, and client secret are correct and that the app registration has appropriate Microsoft Graph API permissions.

  • Access denied errors:
    If you see "Access denied to folder," check SharePoint permissions for the authenticated user or app.

  • Folder not found errors:
    "Folder not found" indicates the specified path does not exist. Double-check the folder path syntax and case sensitivity.

  • Download errors:
    If file content download fails, the error message will be included in the output JSON under downloadError. This may be due to permission issues or transient network problems.

  • Poll interval too short:
    Setting the poll interval below 10 seconds is not allowed and may cause errors.

  • Invalid characters in folder path:
    Folder paths cannot contain characters like < > : " | ? *. Remove such characters to avoid errors.

Links and References

Discussion