{
  "name": "Project: Discord Bot Slash Commands",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "joke_bot",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "4abca13f-f31d-40a7-b041-46b9f055141a",
      "name": "Webhook",
      "webhookId": "c5223e81-9aa9-4a2d-87e4-45c2483412b7"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.data.options[0].value }}",
        "options": {
          "systemMessage": "You are a joke bot for discord. You reply with a joke based on the user input"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        208,
        0
      ],
      "id": "16421d1c-86c7-40df-8b8c-8050adfd8160",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        80,
        208
      ],
      "id": "86b60929-7157-4fd8-822d-f01db94b5483",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "xHWDVrLvQFklSodD",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "for (const item of $input.all()) {\n  const text = item.json.output; // your joke string\n\n  // Replace backslashes first to avoid double-escaping them\n  let escaped = text.replace(/\\\\/g, '\\\\\\\\');\n\n  // Then escape double quotes\n  escaped = escaped.replace(/\"/g, '\\\\\"');\n\n  item.json.escapedContent = escaped;\n}\n\nreturn $input.all();\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        0
      ],
      "id": "8aab9280-850f-44ff-9ac3-8bcaeb08ad7a",
      "name": "Code"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://discord.com/api/v10/webhooks/{{ $('Webhook').item.json.body.application_id }}/{{ $('Webhook').item.json.body.token }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "content",
              "value": "={{ $json.escapedContent }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        768,
        0
      ],
      "id": "03989813-04e8-453d-961e-b5d792e0e3d4",
      "name": "HTTP Request"
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "38c4bbae-e677-4f7a-8e79-0c03d54c5c96",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "281c34c03b9c41f054c536eeb966e9e503918cf7f00e3bc32a5ff9cca85ca255"
  },
  "id": "dke5hdT4s34zlXxX",
  "tags": []
}