{
  "name": "Mensagens",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Webhook').item.json.body.message }}",
        "options": {
          "systemMessage": "=Voce deve utilizar as ferramentas mcp para realizar as tarefas pediddas\n\npara o contexto o tenant \u00e9 {{ $('Webhook').item.json.body.tenant }}\npara o contexto o slug \u00e9 {{ $('Webhook').item.json.body.slug }}\n\nutilize a ferramenta mcp register_cattle_weight para registrar os pesos\nutilize a ferramenta mcp register_application para registrar as aplica\u00e7\u00f5es (confirme o nome do rem\u00e9dio antes de chamar esta fun\u00e7\u00e3o)\npara listar as medica\u00e7\u00f5es use a ferramenta get_medicines_list\npara listar os lotes use a ferramenta get_plots_list\npara datas utilize a ferramenta date_times\npara informa\u00e7\u1ebdos referentes da fazenda utilize a ferramenta answer_tenant_question\npara informa\u00e7\u00f5es gerais sobre agropecuaria utilize a ferramenta answer_public_question\nn\u00e3o sintetize o id dentro das mensagens\npara saber a atividade dos animais em quest\u00e3o de dias sem aparecer, utilize a coluna updated_at"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        320,
        -144
      ],
      "id": "70345b73-4200-4d6e-b9b3-648a639c05fe",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        224,
        48
      ],
      "id": "225e5ec7-4e07-4dad-b30d-212ef1073214",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "endpointUrl": "http://gateway/mcp",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "typeVersion": 1.2,
      "position": [
        624,
        48
      ],
      "id": "0a9e2251-bd7f-48a0-bcd7-c5cb52afad03",
      "name": "MCP Client"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.dateTimeTool",
      "typeVersion": 2,
      "position": [
        512,
        48
      ],
      "id": "e4f9ac41-9352-408f-b8df-b1b7ebcbe649",
      "name": "Date & Time"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "message",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -480,
        -128
      ],
      "id": "39491aa0-e5a9-47e9-b8f3-31e93a4cccec",
      "name": "Webhook"
    },
    {
      "parameters": {
        "respondWith": "allIncomingItems",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        656,
        -144
      ],
      "id": "337245d5-b8e6-45bf-b0f8-4330ae2b9ba5",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Webhook').item.json.body.chat_id }}",
        "tableName": "={{ $('Webhook').item.json.body.tenant }}.n8n_chat_histories"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        384,
        48
      ],
      "id": "b752ecdc-d980-4d61-afb7-3069e4bfb352",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "text": "={{ $json.body.message }}",
        "guardrails": {
          "jailbreak": {
            "value": {
              "threshold": 0.7
            }
          },
          "secretKeys": {
            "value": {
              "permissiveness": "balanced"
            }
          }
        }
      },
      "type": "@n8n/n8n-nodes-langchain.guardrails",
      "typeVersion": 1,
      "position": [
        -304,
        -128
      ],
      "id": "1ccc6436-05ee-4c77-a56e-ea8dc94ced09",
      "name": "Guardrails"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -304,
        48
      ],
      "id": "9f6e8d98-2c9c-485e-8a2a-394dba893b2b",
      "name": "Google Gemini Chat Model1",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"output\": \"perd\u00e3o mas n\u00e3o posso realizar essa a\u00e7\u00e3o\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        0,
        -64
      ],
      "id": "328a92d3-239d-4773-acc0-af38d684ebab",
      "name": "Respond to Webhook1"
    }
  ],
  "connections": {
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "MCP Client": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Guardrails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Guardrails": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Guardrails",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "39393979-96f1-45f0-a8e5-f24a5f9e54c4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "lnh7zGGXI6AOBhwi",
  "tags": []
}