AutomationFlowsAI & RAG › Create Your First AI Agent

Create Your First AI Agent

ByDevCode Journey @devcodejourney on n8n.io

This workflow is designed for anyone who wants to automate AI-driven chat responses integrated with Google Docs and Google Sheets, using the Google Gemini (PaLM) language model via n8n. It’s perfect for teams looking to: Automatically generate AI replies to chat messages, Pull…

Chat trigger trigger★★★☆☆ complexityAI-powered11 nodesAgentGoogle Gemini ToolGoogle Docs ToolHTTP Request ToolGoogle Gemini ChatChat Trigger
AI & RAG Trigger: Chat trigger Nodes: 11 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #9311 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "xh1yv1lvCFV3sHhH",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Create Your First AI Agent",
  "tags": [],
  "nodes": [
    {
      "id": "c5a03f02-86fa-42d4-83fd-7966b49f56ff",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "5334a310-007f-43a7-9f85-f26c7928f5fd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1472,
        -32
      ],
      "parameters": {
        "width": 1072,
        "height": 1152,
        "content": "# Overview\n\nThis **n8n** workflow listens for incoming chat messages, uses **Google Gemini (PaLM)** via **LangChain** to process or reply, optionally reads a **Google Docs** file if mentioned, and logs both the user input and the AI-generated response into chat.\n\n## Features\n- Triggered when a chat message is received\n- Uses Google Gemini (PaLM/Gemini Pro) via LangChain Agent\n- Optionally processes a Google Docs document\n- Modular design \u2013 easy to customize\n\n## \u2705 Requirements\n\n### Tools & Services Needed\n- `n8n` instance (self-hosted or n8n.cloud)\n- Google Gemini API (PaLM or Gemini Pro)\n- Google Sheets and Google Docs access\n- OAuth2 credentials for Google APIs configured in n8n\n\n\n## \ud83d\ude80 How to Use This Workflow\n### 1. Configure Webhook Chat Trigger\n**Node:** `When chat message received`\n- This node captures the user input message\n\n### 2. (Optional) Handle Google Docs Input\n\n**Node:** `Get a document in Google Docs`\n- If the user's message includes a link or ID of a Google Doc, this node retrieves and simplifies it\n- The LangChain Agent can call this automatically when it detects a document reference\n\n### 3. Generate AI Response\n\n**Node:** `Google Gemini Chat Model`\n- LangChain routes message through the Gemini model\n- It generates a smart, contextual response, optionally using tools (e.g., Docs reader)\n\n## \ud83d\ude4b For Help & Community\n\n- \ud83d\udc7e Discord: [n8n channel](https://discord.gg/9SDFKGnh2Y)\n- \ud83c\udf10 Website: [devcodejourney.com](https://devcodejourney.com)\n- \ud83d\udd17 LinkedIn: [Connect with Shakil](https://www.linkedin.com/in/shakilpg/)\n- \ud83d\udcf1 WhatsApp Channel: [Join Now](https://whatsapp.com/channel/0029Vb5l6JuDTkK5BRORNn0B)\n- \ud83d\udcac Direct Chat: [Message Now](https://wa.me/8801316320957)"
      },
      "typeVersion": 1
    },
    {
      "id": "092b6a15-91e6-4ee9-8be7-fc45d3fd7d0c",
      "name": "Gemini",
      "type": "@n8n/n8n-nodes-langchain.googleGeminiTool",
      "position": [
        144,
        272
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "model",
              "content": "Give me user user-friendly reply. Don't give me a robotic type relay."
            }
          ]
        }
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ffb50b58-3388-4504-b711-bf1b5c12bdbf",
      "name": "Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        272,
        272
      ],
      "parameters": {
        "simple": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Simplify', ``, 'boolean') }}",
        "operation": "get",
        "documentURL": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Doc_ID_or_URL', ``, 'string') }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "b0f6e69c-c23b-4a6d-add0-5f7f181c0174",
      "name": "Request",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        32,
        272
      ],
      "parameters": {
        "url": "https://google.cm/",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "32a851d3-2e78-4be9-907d-81a6303399b0",
      "name": "Gemini Chat",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -160,
        272
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "315446fa-9dbe-474e-870f-719e616f1d15",
      "name": "Chat message",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -304,
        0
      ],
      "parameters": {
        "public": true,
        "options": {},
        "initialMessages": "Hi Nani! \ud83d\udc4b"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0be1fa1e-e723-42bc-8374-7500f994180e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 448,
        "height": 336,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n---\n### Tools you can change/add another tool as your wish but need this modal API key and give some data what you want to give replay type"
      },
      "typeVersion": 1
    },
    {
      "id": "6691a7df-166f-4061-9409-6c2fe2d6d3c2",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 336,
        "content": "\n\n\n\n\n\n\n\n\n\n\n---\n### chat modal you can change/add another modal as your wish but need this modal API key"
      },
      "typeVersion": 1
    },
    {
      "id": "35dfef59-06e5-4542-87cd-83ad6b60fcb7",
      "cid": "Ikx1Y2FzIFBleXJpbiI",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "\u00a9 2025 Lucas Peyrin",
      "creator": "Lucas Peyrin",
      "position": [
        -368,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 268,
        "height": 236,
        "content": "Activate this workflow and share the public chat URL to let others talk to your AI Agent!"
      },
      "typeVersion": 1
    },
    {
      "id": "499298ba-6976-4e30-b045-7cce8d20c4ee",
      "cid": "Ikx1Y2FzIFBleXJpbiI",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "\u00a9 2025 Lucas Peyrin",
      "creator": "Lucas Peyrin",
      "position": [
        -80,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 396,
        "height": 348,
        "content": "## Your AI agent can:\n1. **Receive** messages from the chat\n2. **Select** the right tools (e.g., weather, news, email)\n3. **Respond** with live, helpful answers\n\n\nAdjust your agent\u2019s **System Message** thinking, behavior, and replies.\n\n\n\n\n\n\n\n\n\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "a1f24637-344d-4441-86b6-c452a01aef65",
  "connections": {
    "Docs": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Request": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        []
      ]
    },
    "Gemini Chat": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chat message": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow is designed for anyone who wants to automate AI-driven chat responses integrated with Google Docs and Google Sheets, using the Google Gemini (PaLM) language model via n8n. It’s perfect for teams looking to: Automatically generate AI replies to chat messages, Pull…

Source: https://n8n.io/workflows/9311/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

ModelRouter. Uses chatTrigger, agent, modelSelector, httpRequest. Chat trigger; 28 nodes.

Chat Trigger, Agent, Model Selector +8
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Google Calendar Tool, Gmail Tool, Chat Trigger +6
AI & RAG

Use Cases Quickly plan a trip by providing your destination and dates. Get real-time flight and accommodation details for a planned vacation. Receive a summary of your travel plans directly in your in

Chat Trigger, Agent, Output Parser Structured +3
AI & RAG

Reasoning_Harness_Eval_Workflow. Uses lmChatOpenAi, httpRequestTool, agent, chatTrigger. Chat trigger; 17 nodes.

OpenAI Chat, HTTP Request Tool, Agent +3
AI & RAG

This template is a complete, hands-on tutorial that lets you build and interact with your very first AI Agent.

Memory Buffer Window, Google Gemini Chat, OpenAI Chat +8