{
  "name": "Di\u00e1rio autom\u00e1tico",
  "nodes": [
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "llama-3.1-8b-instant",
          "mode": "list",
          "cachedResultName": "LLAMA-3.1-8B-INSTANT"
        },
        "responses": {
          "values": [
            {
              "content": "=Voc\u00ea \u00e9 um assistente pessoal especializado em an\u00e1lise de dados estruturados. Sua \u00fanica fun\u00e7\u00e3o \u00e9 ler di\u00e1rios pessoais e extrair informa\u00e7\u00f5es rigorosamente no formato JSON para um banco de dados no Notion.\n\nRegras R\u00edgidas de Categoriza\u00e7\u00e3o:\nEscolha EXATAMENTE UMA op\u00e7\u00e3o para o campo \"categoria\":\nReflex\u00e3o, Estudos, Carreira, Relacionamento, Fam\u00edlia, Sa\u00fade, Finan\u00e7as, Filosofia, Decis\u00e3o, Conquista, Frustra\u00e7\u00e3o, Vida pessoal, Outro.\n\nRegras R\u00edgidas para \"tags\":\nRetorne uma lista contendo no M\u00c1XIMO 3 tags.\nVOC\u00ca EST\u00c1 OBRIGADO A USAR APENAS AS TAGS DESTA LISTA:\nIA, Programa\u00e7\u00e3o, Java, Spring, Estudos, Faculdade, Trabalho, Carreira, Finan\u00e7as, Sa\u00fade, Academia, Relacionamento, Fam\u00edlia, Filosofia, Livros, Objetivos, Decis\u00f5es, Reflex\u00e3o, Vida pessoal, Grafipel, Encontro.\n\nATEN\u00c7\u00c3O (REGRA ABSOLUTA): \u00c9 TERMINANTEMENTE PROIBIDO inventar, criar ou sugerir qualquer tag que n\u00e3o esteja escrita exatamente como na lista acima. Se o texto n\u00e3o se encaixar em nenhuma dessas tags, retorne uma lista vazia: [].\n\nAnalise os dados abaixo:\nASSUNTO: {{ $json[\"Subject\"] }}\nTEXTO DO E-MAIL: {{ $json[\"snippet\"] }}\nID DO E-MAIL: {{ $json[\"id\"] }}\nResponda \u00daNICA e EXCLUSIVAMENTE com um objeto JSON v\u00e1lido. N\u00e3o inclua sauda\u00e7\u00f5es, explica\u00e7\u00f5es e n\u00e3o use blocos de formata\u00e7\u00e3o markdown (como ```json). Entregue apenas as chaves e valores abaixo:\n\n{\n\"titulo\": \"Crie um t\u00edtulo curto e marcante para esta entrada\",\n\"categoria\": \"Escolha UMA op\u00e7\u00e3o exata da lista de categorias\",\n\"humor\": \"Escolha UMA op\u00e7\u00e3o exata entre: Muito mal, Mal, Neutro, Bem, Muito bem, Reflexivo, Ansioso, Motivado, Frustrado, Confuso\",\n\"importancia\": \"Escolha UMA entre: Baixa, M\u00e9dia, Alta\",\n\"status\": \"Escolha UMA entre: Apenas registro, Preciso refletir, Preciso agir, Resolvido\",\n\"tags\": [\"TagDaLista1\", \"TagDaLista2\"],\n\"resumo\": \"Um resumo direto de 2 a 3 frases capturando a ess\u00eancia do e-mail.\",\n\"precisa_de_acao\": false\n}"
            }
          ]
        },
        "builtInTools": {},
        "options": {
          "store": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.3,
      "position": [
        336,
        0
      ],
      "id": "d8f2a391-0134-49f3-932b-a47110fcd5d6",
      "name": "Message a model",
      "retryOnFail": true,
      "waitBetweenTries": 3000,
      "executeOnce": false,
      "maxTries": 5,
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "resource": "databasePage",
        "dataSourceId": {
          "__rl": true,
          "value": "SEU_DATABASE_ID_AQUI",
          "mode": "list",
          "cachedResultName": "Di\u00e1rio",
          "cachedResultUrl": "https://app.notion.com/p/SEU_LINK_AQUI"
        },
        "title": "={{ $('Gmail Trigger').item.json.Subject }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Categoria|select",
              "selectValue": "={{ JSON.parse($json.output[0].content[0].text.replace(/```json/gi, '').replace(/```/g, '').trim()).categoria }}"
            },
            {
              "key": "Humor|select",
              "selectValue": "={{ JSON.parse($json.output[0].content[0].text.replace(/```json/gi, '').replace(/```/g, '').trim()).humor }}"
            },
            {
              "key": "Status|select",
              "selectValue": "={{ JSON.parse($json.output[0].content[0].text.replace(/```json/gi, '').replace(/```/g, '').trim()).status }}"
            },
            {
              "key": "Import\u00e2ncia|select",
              "selectValue": "={{ JSON.parse($json.output[0].content[0].text.replace(/```json/gi, '').replace(/```/g, '').trim()).importancia }}"
            },
            {
              "key": "Precisa de a\u00e7\u00e3o|checkbox",
              "checkboxValue": "={{ JSON.parse($json.output[0].content[0].text.replace(/```json/gi, '').replace(/```/g, '').trim()).precisa_de_acao === true }}"
            },
            {
              "key": "Tags|multi_select",
              "multiSelectValue": "={{ JSON.parse($json.output[0].content[0].text.replace(/```json/gi, '').replace(/```/g, '').trim()).tags.filter(tag => typeof tag === 'string' && tag.trim() !== '') }}"
            },
            {
              "key": "Gmail|url",
              "urlValue": "={{ \"https://mail.google.com/mail/u/0/#inbox/\" + $('Gmail Trigger').item.json.id }}"
            },
            {
              "key": "Resumo|rich_text",
              "textContent": "={{ JSON.parse($json.output[0].content[0].text.replace(/```json/gi, '').replace(/```/g, '').trim()).resumo }}"
            },
            {
              "key": "Data|date",
              "date": "={{ new Date(Number($('Gmail Trigger').item.json.internalDate)).toISOString() }}",
              "timezone": "America/Sao_Paulo"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 3,
      "position": [
        592,
        0
      ],
      "id": "d729ee92-d20a-414b-b586-06bb756ddf44",
      "name": "Create a database page",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "filters": {
          "q": "label:Di\u00e1rio"
        }
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.4,
      "position": [
        208,
        0
      ],
      "id": "f635624c-879b-4b7d-86ba-26fbb4f8d079",
      "name": "Gmail Trigger",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Message a model": {
      "main": [
        [
          {
            "node": "Create a database page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a database page": {
      "main": [
        []
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "660f41f7-e763-4e78-9acb-d3ce55f88252",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodeGroups": [],
  "id": "GwfMHxQjaEohKfg8",
  "tags": [
    {
      "name": "Pessoal",
      "id": "OYRcdmHkm6EbTFz7",
      "updatedAt": "2026-07-29T13:56:29.789Z",
      "createdAt": "2026-07-29T13:56:29.789Z"
    }
  ]
}