arrow_back
hub

Build AI Chatbots (n8n)

CPS Lab Workshops

Step 1: Start n8n (Choose a Method)

Option A: n8n Cloud (Easiest, No Install)
  1. Click the link below to go to the n8n website.
  2. Sign up for a free account using your Google account or email.
  3. Once you reach the dashboard, click "Add Workflow".
Option B: Local Terminal (Advanced)
  1. Open your computer's terminal (Command Prompt).
  2. Type npm install -g n8n and press Enter.
  3. Wait for the download to finish.
  4. Type n8n and press Enter to start the server.
  5. Open http://localhost:5678 in your browser.

Step 2: Copy the Demo Template

Scroll down to the 'Starter Template' section below and click the Copy button. n8n workflows are just JSON code, making them incredibly easy to share!

Step 3: Paste and Build

Go to your open n8n browser tab. Create a new workflow, click anywhere on the empty grid, and press Ctrl+V (or Cmd+V). The CPS Lab Sensor Bot structure will magically appear!

Step 4: Add Keys & Test

Double click the 'OpenAI' node, add your API key (create a credential), and click 'Execute Workflow'. A chat window will appear for you to test your new AI Agent!
cps-sensor-bot-template.json
{
  "nodes": [
    {
      "parameters": {},
      "id": "chat-trigger",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [ 100, 300 ]
    },
    {
      "parameters": {
        "url": "https://api.yourcpslab.com/sensors/live",
        "options": {}
      },
      "id": "fetch-sensors",
      "name": "Fetch CPS Sensor Data (API)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [ 300, 300 ]
    },
    {
      "parameters": {
        "model": "gpt-3.5-turbo"
      },
      "id": "openai-model",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [ 500, 450 ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are the CPS Lab Assistant. The user just asked a question. Here is the live sensor data from the lab: {{ $json.data }}\n\nPlease answer their question based on the sensor data."
      },
      "id": "analyze-sensor",
      "name": "Analyze Sensor Data",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [ 500, 300 ]
    }
  ],
  "connections": {
    "Chat Trigger": {
      "main": [ [ { "node": "Fetch CPS Sensor Data (API)", "type": "main", "index": 0 } ] ]
    },
    "Fetch CPS Sensor Data (API)": {
      "main": [ [ { "node": "Analyze Sensor Data", "type": "main", "index": 0 } ] ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [ [ { "node": "Analyze Sensor Data", "type": "ai_languageModel", "index": 0 } ] ]
    }
  }
}