AutomationFlowsAI & RAG › Chat with Gemini AI via SSH

Chat with Gemini AI via SSH

Original n8n title: Chat with Gemini AI Through Local Cli via SSH

ByAlexandru Florea @elitiv on n8n.io

This workflow allows you to integrate the Google Gemini CLI into your n8n AI Agents. It is designed for self-hosted n8n instances and enables you to chat with the Gemini CLI running on your local machine or server via SSH.

Chat trigger trigger★★★☆☆ complexityAI-powered13 nodesChat TriggerMemory Buffer WindowGoogle Gemini ChatTool WorkflowAgentSshExecute Workflow Trigger
AI & RAG Trigger: Chat trigger Nodes: 13 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #11843 — 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
{
  "nodes": [
    {
      "id": "af51d7f3-7c8d-4a59-b2ba-93702b550edb",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "mode": "webhook",
        "public": true,
        "options": {
          "responseMode": "streaming",
          "loadPreviousSession": "memory"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "40f5f9d8-34fd-412a-901b-2cead6ff5509",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        32,
        240
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "ad77efae-206f-4d22-82e7-5cdbdd896eaa",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        352,
        240
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "18c36cb6-2050-4df4-85cb-3dcd4a6e5a5b",
      "name": "Call 'Gemini CLI'",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        592,
        256
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "wyxh9ceGDzJvNCLT",
          "cachedResultUrl": "/workflow/wyxh9ceGDzJvNCLT",
          "cachedResultName": "Gemini CLI"
        },
        "description": "CLI tool",
        "workflowInputs": {
          "value": {
            "prompt": "={{ $json.chatInput }}"
          },
          "schema": [
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "prompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6c831fec-f997-4056-b463-cdda84998203",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        384,
        0
      ],
      "parameters": {
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "Every time you MUST use the CLI tool before you provide final answer! "
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "8e3ef621-a4d6-4c9e-9885-01edc893add9",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        736,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2c25e4b0-c8b9-456d-b879-84c8bb5e8270",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        -224
      ],
      "parameters": {
        "width": 1360,
        "height": 672,
        "content": "## Connect Gemini CLI with your n8n workflow\n\nThis concept demonstrates how to use the Gemini CLI as a tool within n8n. It integrates a simple AI Chat interface with a backend CLI tool running on your server.\n\n**NOTE:** This allows you to leverage the power of Gemini (via your Google Account) directly from your terminal. This is ideal for self-hosted setups where you might want the LLM to have access to internal folders or files via the command line.\n\n### Pre-requirements\n1. **n8n Self-hosted**\n2. **NodeJS >= 20.x** installed on the host.\n3. **Gemini CLI** installed (`npm install -g @google/gemini-cli`)\n4. **SSH Access**: n8n needs SSH access to the host machine to execute the commands.\n\n### Configuration Instructions\n**Step 1: Separate the Workflows**\nThis template contains TWO parts. You must move the bottom part (Sub-workflow) to a new workflow file and save it.\n\n**Step 2: Link the Tool**\nIn the \"Call 'Gemini CLI'\" node above, select the new workflow you just saved.\n\n**Step 3: Setup SSH**\nUpdate the \"Execute a command\" node with your host credentials.\n\n\n---\n### Support & Customization\nIf you have questions, need help setting this up, or want to request more information:\n* **Contact:** Alex\n* **Email:** alex@elitiv.com\n* **Website:** [www.elitiv.com](https://www.elitiv.com)"
      },
      "typeVersion": 1
    },
    {
      "id": "ba8b7e85-5d25-4640-8bb6-7329ce3c6f5b",
      "name": "Execute a command",
      "type": "n8n-nodes-base.ssh",
      "position": [
        320,
        -528
      ],
      "parameters": {
        "command": "=gemini \"{{ $json.prompt }}\""
      },
      "typeVersion": 1
    },
    {
      "id": "0184cb0f-93f8-4b4f-8ea4-c829fa6e5f32",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        112,
        -528
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "prompt"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "6e4c5103-e1c1-4e4e-84d6-66a1394ac34a",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        528,
        -528
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ff065868-795e-4e55-83f7-d580e25a147b",
              "name": "answer",
              "type": "string",
              "value": "={{ $json.stdout }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "375aba18-1eda-44dd-94e1-a42bbf6bc1fb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -752
      ],
      "parameters": {
        "color": 4,
        "width": 752,
        "height": 416,
        "content": "## Sub-workflow (ACTION REQUIRED: Move to separate workflow)\n\n**NOTE** You must copy these nodes, save them as a new workflow, and then select that new workflow in the \"Call Gemini CLI\" node above.\n\n* This will execute: gemini \"{{ $json.prompt }}\" in the terminal via SSH\n* Returns the LLM response message"
      },
      "typeVersion": 1
    },
    {
      "id": "ed45a15f-c09c-47d5-a31e-ce17ff51324a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -224
      ],
      "parameters": {
        "color": 6,
        "width": 752,
        "height": 672,
        "content": "## AI Agent Configuration\n\n**NOTE:** This agent is configured to use the Gemini CLI (via the sub-workflow) as a custom tool.\n\n* **System Prompt:** Customize the prompt to define the agent's persona. Ensure you explicitly instruct the agent on when it should use the \"Gemini CLI\" tool to process data or answer questions.\n* **Extensibility:** You can easily attach additional tools here (e.g., Google Search, Wikipedia) to enhance the agent's capabilities further."
      },
      "typeVersion": 1
    },
    {
      "id": "c60bc8ee-0cf1-42a6-99aa-e6cfa7bd0bed",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -224
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 672,
        "content": "## Chat Interface Trigger\n\n* **Customizable:** This trigger initiates the chat conversation and can be customized to fit your specific use case.\n* **Embeddable:** You can use this workflow as a backend for n8n's Chat UI, embedding it into any website or application."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "When chat message received",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Call 'Gemini CLI'": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Execute a command": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Execute a command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

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

About this workflow

This workflow allows you to integrate the Google Gemini CLI into your n8n AI Agents. It is designed for self-hosted n8n instances and enables you to chat with the Gemini CLI running on your local machine or server via SSH.

Source: https://n8n.io/workflows/11843/ — 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

This Chatbot automates the process of discovering job openings and generating tailored job application emails.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

This n8n template provides a powerful AI-powered chatbot that acts as your personal Spotify DJ. Simply tell the chatbot what kind of music you're in the mood for, and it will intelligently create a cu

OpenAI Chat, Spotify, Chain Llm +7
AI & RAG

This workflow is a two-part intelligent content creation system built in n8n, designed to generate professional and on-brand LinkedIn posts.

Lm Chat Mistral Cloud, Tool Think, Agent +4
AI & RAG

I prepared a detailed guide showcasing the process of building an AI agent that interacts with a Snowflake database using n8n. This setup enables conversational querying, secure execution of SQL queri

Chat Trigger, Agent, OpenAI Chat +5
AI & RAG

Description: Overview This workflow generates automated revenue and expense comparison reports from a structured Google Sheet. It enables users to compare financial data across the current period, las

Lm Chat Deep Seek, Memory Buffer Window, Tool Workflow +4