{
  "name": "n8n image bot",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.last_user_message }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You are an assistant for a fast food restaurant. Always say hello to the user, inform that he is talking with a Restaurant and offer a simple list for the menu. Provide a brief description and price for each of the following items and add the image link avoid using \\n in the text.\n\nPizza\nhttps://images.pexels.com/photos/842519/pexels-photo-842519.jpeg\nDescription: A delicious pizza with a variety of toppings including pepperoni, mushrooms, and extra cheese.\nPrice: $12.99\n\nHotdog\nhttps://images.pexels.com/photos/30635915/pexels-photo-30635915.jpeg\nDescription: A classic hotdog with a juicy sausage, topped with mustard, ketchup, onions, and relish.\nPrice: $4.99\n\nBurger\nhttps://images.pexels.com/photos/1251198/pexels-photo-1251198.jpeg\nDescription: A mouth-watering burger with a beef patty, lettuce, tomato, cheese, and special sauce.\nPrice: $7.99"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        140,
        0
      ],
      "id": "9f6c2ac2-194f-4dcd-9660-a14abc00f09f",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": "gpt-4o",
        "options": {
          "responseFormat": "text"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        80,
        240
      ],
      "id": "ea2e29e9-c938-4171-ada5-737069386865",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.p.2chat.io/open/whatsapp/send-message",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-User-API-Key",
              "value": "UAK85276705-e4c6-4a65-a8b3-01c69a406cdd"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"to_number\": \"{{ $('Webhook').item.json.body.to_number }}\",\n  \"from_number\": \"+573054684700\",\n  \"text\": \"{{ $json.output }}\",\n  \"url\": \"{{ $json.url }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        820,
        0
      ],
      "id": "3a0dc4bc-9e72-4392-a581-db767bf14393",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "2chat-food",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -140,
        0
      ],
      "id": "d0f538f2-b4d7-42d0-a787-2136ac6789de",
      "name": "Webhook"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Webhook').item.json.body.to_number }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        220,
        240
      ],
      "id": "a29b95a7-7f67-4583-9047-ed4c559b35ca",
      "name": "Window Buffer Memory"
    },
    {
      "parameters": {
        "language": "python",
        "pythonCode": "import re\n# Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor item in _input.all():\n  url =re.search('http.+\\/\\/.+[a-z]', item.json.output)\n  if url:\n    item.json.url = url[0]\n  else:\n    item.json.url = \"\"\n  item.json.output=item.json.output.replace(\"\\n\",\"\")\nreturn _input.all()"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        0
      ],
      "id": "466d4838-d638-42ce-9e20-f468dbb884e1",
      "name": "Code"
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4d9457df-05a2-4599-bbdd-673d5324bc4a",
  "id": "oisSgR8UnZ7wLsoC",
  "tags": []
}