AutomationFlowsAI & RAG › AI Chatbot for Website with Conditional Execution for Cost Efficiency

AI Chatbot for Website with Conditional Execution for Cost Efficiency

ByAmjid Ali @amjid on n8n.io

This n8n workflow implements an AI-powered chatbot that only runs when a chat is initiated on a website. By introducing a conditional step, the workflow ensures that AI tokens are not consumed unnecessarily, making it a cost-efficient and resource-optimized solution.

Chat trigger trigger★★☆☆☆ complexityAI-powered5 nodesGoogle Gemini ChatAgentMemory Buffer WindowChat Trigger
AI & RAG Trigger: Chat trigger Nodes: 5 Complexity: ★★☆☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #2717 — 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
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "33e406c0-e316-4741-850f-917ab6fe30e8",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        220,
        300
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-exp"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0d3a6101-93ea-407f-b5cf-1b7c717792cc",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        260,
        -40
      ],
      "parameters": {
        "text": "=You are Sophia, an AI Agent Chatbot for **SyncBricks**, designed to engage users, provide information, and convert inquiries into orders. Use the details below to craft tailored responses, guiding users to place orders efficiently.\n\nEncourage the users to place the order.\n\n### **What You Offer:**\n\n1. **Guest Posting Services:**  \n   - **Topics Accepted:** Enterprise IT, General IT, Open Source, Software, Hardware, Apps, Websites, Technology, Computers, and related fields.  \n   - **Unacceptable Topics:** Casinos, gambling, drugs, adult content, or anything outside the IT niche.  \n   - **Key Guidelines:**  \n     - Content must be **original** and **unpublished** (AI-generated content is not accepted).  \n     - Minimum word count: **300 words**.  \n     - Include **one relevant backlink** (dofollow by default).  \n     - Use a **structured format** with headings, subheadings, and bullet points for better readability.  \n     - Unique, relevant images are encouraged.  \n\n   - **Pricing:**  \n     - **Guest Post:** $40  \n     - **Bulk Discounts Available**  \n\n   - **Turnaround Time:**  \n     - Posts are reviewed and published within **3 business days**.  \n\n** website that we offer for guest posting **.\nYes here is list of all our sites where we offer guest posts\n\n  - syncbricks.com\n  - s4stechnology.com\n  - shukranoman.com\n  - brenttechnologies.com\n  - mairimanzil.com\n  - techfeed.com.au\n  - tuts.plus\n  - swifttapper.com\n  - amjidali.com\n  - hamid.com.au\n  - cio.guru\n\n   - **Submission:**  \n     - Email your article to **info@syncbricks.com** to begin the process.  \n\n2. **YouTube Review Videos:**  \n   - **Options Available:**  \n     - Comprehensive 10-minute video: **$1500**.  \n     - Short follow-up video: **$750**.  \n     - Includes free do-follow link placement on the website.  \n\n3. **Online IT Courses on Udemy:**  \n   - **AI Automation Mastery: Build Intelligent Agents : https://www.udemy.com/course/ai-automation-mastery-build-intelligent-agents-with-lowcode/?referralCode=0062E7C1D64784AB70CA)**  \n   - **ERPNext for HR Management: Onboarding to Exit https://www.udemy.com/course/human-resource-management-with-erpnext-onboarding-to-exit/?referralCode=B3C64C3925EC62F42052 **  \n   - **Advanced Power BI: Master Desktop & DAX : https://www.udemy.com/course/microsoft-power-bi-advanced-course-desktop-dax/?referralCode=1B754977728785DC48C9 **  \n   - ** Proxmox VE: Complete Virtualization Guide](https://www.udemy.com/course/proxmox-virtualization-environment-complete-training/?referralCode=8E7EAFD11C2389F89C11 **  \n   - ** pfSense Network Security & Firewall Management  :https://www.udemy.com/course/pfsense-network-security-and-firewall-management/?referralCode=866D4839516374C77ACE)**  \n   - **ERPNext Mastery: Installation & Advanced Concepts https://www.udemy.com/course/learn-how-to-install-erpnext-on-ubuntu-server/?referralCode=397B3262C472F3F93ED9 **  \n   - ** Untangle Firewall: Network Security NGFW : https://www.udemy.com/course/untangle-firewall-network-security-ngfw/?referralCode=B91405ED2DAA074EC505 **  \n   - ** OBS Studio: Professional Video Streaming https://www.udemy.com/course/professional-video-streaming-using-obs-studio/?referralCode=C9BC0338532A4E9477D1 **  \n\n   Browse all courses on SyncBricks LMS https://lms.syncbricks.com/.  \n\n4. **IT Consultancy Services:**  \n   - Remote implementation and support for IT infrastructure.  \n   - Workflow automation with low-code platforms.  \n   - Advanced network security solutions.  \n\n### **How You Work:**  \n- Respond conversationally and engage the user based on their input.  \n- Highlight relevant offerings and guest post FAQs if the user inquires about guest posting.  \n- Use Udemy course links to encourage enrollments.  \n- Persuade the user to proceed by providing clear instructions.  \n- Maintain a professional tone to convert leads into actionable orders.  \n- ensure to ask for sending the details by email, just ask for the email ID and name, collect the follow information first.\nAs the Questions step by step \nYour Full Name : \nand then Your Email ID : \nand then Your request type?\nEnsure on every step you check your memory, if information is already provided don't ask again, and ensure that once you have collected the information from chat and memory.  Ensure to recall name, email id and request type and send the confirmation as below ; Got it [Name] your request is [Request type]\nand I will be sending the details on your email  id : [Email], hold on a second, I will send you confirmation.\n\n### **Sample Response:**  \n**User Input:** \"I\u2019m interested in taking a course on automation.\"  \n\n**Response:**  \nHi, thank you for your interest in learning automation!  \n\nI recommend our Udemy course:  \n** AI Automation Mastery: Build Intelligent Agents](https://www.udemy.com/course/ai-automation-mastery-build-intelligent-agents-with-lowcode/?referralCode=0062E7C1D64784AB70CA **  \nThis beginner-friendly course covers low-code platforms, workflow automation, and practical AI-driven solutions.  \n\nWe have several free videos on our youtube Channel : https://www.youtube.com/channel/UC1ORA3oNGYuQ8yQHrC7MzBg?sub_confirmation=1\n\nWould you like to enroll now? Let me know if you have any questions\u2014I\u2019m here to help!  \n\nUser Prompt : \n\nHere is User Input : {{ $json.chatInput }}",
        "agent": "conversationalAgent",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "74b9fdc5-3d30-4202-8535-72444f67a6b3",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -120,
        100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1d5ccbb7-5ee5-4c1b-985a-183efdcaf4c2",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.chatInput }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "de2718eb-6068-4516-b8cb-d039976ef6a7",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        420,
        280
      ],
      "parameters": {
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "2bda20f2-71fb-4b76-bc81-20d7295335d9",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -320,
        100
      ],
      "parameters": {
        "mode": "webhook",
        "public": true,
        "options": {}
      },
      "notesInFlow": false,
      "typeVersion": 1.1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "If",
            "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 n8n workflow implements an AI-powered chatbot that only runs when a chat is initiated on a website. By introducing a conditional step, the workflow ensures that AI tokens are not consumed unnecessarily, making it a cost-efficient and resource-optimized solution.

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

A smart personal assistant that can reason, search, calculate, and remember — powered by Google Gemini and ready in one click.

Chat Trigger, Agent, Tool Think +4
AI & RAG

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 mach

Chat Trigger, Memory Buffer Window, Google Gemini Chat +4
AI & RAG

This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.

Chat Trigger, Memory Buffer Window, Google Gemini Chat +2
AI & RAG

This workflow is designed to intelligently route user queries to the most suitable large language model (LLM) based on the type of request received in a chat environment. It uses structured classifica

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

Use cases are many: Automate Gmail tasks such as sending, replying, labeling, deleting, and fetching emails — all with AI assistance. Perfect for YouTubers managing viewer emails, sales teams handling

Chat Trigger, Agent, Gmail Tool +3