วิธีการต่อ n8n กับ Microsoft

3 min read 6 days ago
Published on Aug 31, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through connecting n8n with Microsoft services such as OneDrive, Excel 365, and MS Teams. By following these steps, you will learn how to automate workflows and integrate data across these platforms, enhancing your productivity and efficiency.

Step 1: Setting Up n8n

  1. Install n8n:
    • You can install n8n locally or use a hosted version. Refer to the n8n installation guide for detailed instructions.
  2. Access n8n:
    • Once installed, open n8n in your web browser by navigating to http://localhost:5678.

Step 2: Connect to Microsoft OneDrive

  1. Create a Microsoft App:

    • Go to the Azure Portal and sign in.
    • Navigate to "Azure Active Directory" > "App registrations" > "New registration".
    • Name your app and set the redirect URI to http://localhost:5678/rest/oauth2/callback.
    • Note the Application (client) ID and Directory (tenant) ID.
  2. Set Up API Permissions:

    • In your app settings, go to "API permissions".
    • Click "Add a permission" > "Microsoft Graph" > "Delegated permissions".
    • Add permissions like Files.ReadWrite, Files.ReadWrite.All, and any other relevant permissions.
  3. Generate Client Secret:

    • Under "Certificates & secrets", click "New client secret".
    • Copy the secret value as you will need it later.
  4. Configure n8n:

    • In n8n, create a new workflow.
    • Add a new node and select "Microsoft OneDrive".
    • Choose "OAuth2" as the authentication type.
    • Input the Client ID, Client Secret, and Tenant ID you obtained earlier.

Step 3: Connect to Excel 365

  1. Repeat Microsoft App Steps:

    • Use the same app you created for OneDrive, or create a new one if needed.
    • Ensure you have permissions for Excel.ReadWrite, Excel.ReadWrite.All.
  2. Configure Excel Node in n8n:

    • In your n8n workflow, add a new node for "Microsoft Excel".
    • Select "OAuth2" for authentication, using the same credentials as before.
  3. Define Actions:

    • Specify actions you want to perform, such as reading data from a spreadsheet or writing data to it.

Step 4: Connect to MS Teams

  1. API Permissions:

    • Ensure your app also has permissions for Teams.ReadWrite and Teams.ReadWrite.All.
  2. Configure MS Teams Node in n8n:

    • Add a new node for "Microsoft Teams" in your workflow.
    • Again, use OAuth2 authentication with the credentials from your registered app.
  3. Set Up Actions:

    • Define what actions you want to integrate with Teams, such as sending messages or creating teams.

Practical Tips

  • Testing Connections: After setting up each node, test the connection to ensure it's working properly.
  • Error Handling: Implement error handling in your workflows to manage API errors gracefully.
  • Documentation: Keep the Microsoft Graph API documentation handy for reference on available endpoints and permissions.

Conclusion

By following these steps, you have successfully connected n8n with Microsoft OneDrive, Excel 365, and MS Teams. This integration allows you to automate workflows across various Microsoft services. For further exploration, consider creating more complex workflows or integrating additional Microsoft services to enhance your automation capabilities.