สอน ติดตั้ง n8n และ เชื่อม Google + AI ฉบับจัดเต็ม และ Cloudflare Tunnel + Custom Domain ของคุณ!

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 the installation and setup of n8n, a powerful automation tool that integrates with Google services and AI technologies. You will learn how to connect n8n with Google Sheets, Docs, and Drive, set up AI tools like Ollama and OpenRouter, and secure your setup using Cloudflare Tunnel with a custom domain. This comprehensive guide is perfect for anyone looking to create a robust AI automation system.

Step 1: Install n8n

  • Begin by installing Node.js if you haven't already. You can download it from the Node.js website.
  • Once Node.js is installed, open your terminal and run the following command to install n8n globally:
    npm install n8n -g
    
  • After installation, start n8n by executing:
    n8n
    
  • Ensure n8n runs without errors. You can access the n8n editor at http://localhost:5678.

Step 2: Set Up Google Cloud Project

  • Go to the Google Cloud Console.
  • Create a new project by clicking on the project dropdown and selecting "New Project."
  • Once your project is created, navigate to the "API & Services" dashboard.
  • Enable the APIs for Google Sheets, Google Docs, and Google Drive by clicking on "Enable APIs and Services."

Step 3: Create Service Account and Credentials

  • In the API & Services section, click on "Credentials."
  • Select "Create Credentials" and choose "Service Account."
  • Fill in the required details and click "Create."
  • Once created, click on the service account to manage its permissions.
  • Add the necessary roles, such as "Editor" or "Viewer," depending on your needs.
  • Generate a JSON key file for the service account and save it securely.

Step 4: Connect n8n with Google Services

  • In the n8n editor, add a new node by clicking on the "+" sign.
  • Search for and select "Google Sheets" (or Docs/Drive as needed).
  • Use the credentials from the JSON key file to authenticate the Google service.
  • Configure the node according to your automation requirements (e.g., read from or write to a spreadsheet).

Step 5: Install Ollama for Local AI

  • Download Ollama from Ollama's website.
  • Follow the installation instructions specific to your operating system.
  • Once installed, you can run Ollama using the command line. For example:
    ollama run <model_name>
    

Step 6: Set Up OpenRouter as AI Gateway

  • Visit the OpenRouter website and create an account.
  • Follow the documentation to integrate OpenRouter with your applications.
  • Use OpenRouter to manage AI models and facilitate communication with n8n.

Step 7: Configure Cloudflare Tunnel

  • Sign up for a Cloudflare account if you don't have one at Cloudflare.
  • Once logged in, navigate to the "Tunnel" section and create a new tunnel.
  • Follow the prompts to connect your local n8n instance to Cloudflare.
  • Cloudflare will provide a public URL to securely access your n8n setup from the internet.

Step 8: Set Up Custom Domain with Namecheap

  • Go to Namecheap and purchase a domain if you haven't already.
  • In your domain settings, set up DNS records to point to the Cloudflare tunnel URL.
  • Ensure that the domain is properly configured to resolve to your n8n instance.

Conclusion

By following these steps, you will have successfully set up n8n integrated with Google services and AI tools, secured through Cloudflare Tunnel and accessible via a custom domain. This system allows for powerful automation capabilities, providing a bridge between various services and AI functionalities. For further enhancements, consider exploring additional integrations or automations within n8n. Happy automating!