0% acharam este documento útil (0 voto)
23 visualizações8 páginas

Post em Blog

O documento descreve um fluxo de trabalho automatizado que busca notícias sobre tecnologia, filtra as novas com base em temas usados, gera um artigo sobre elas e envia um e-mail com o conteúdo gerado. Ele utiliza a API de notícias, Google Sheets para armazenar temas, e OpenAI para criar o artigo. O fluxo é acionado por um gatilho programado e envolve várias etapas de processamento e filtragem de dados.

Enviado por

Fabio Aragao
Direitos autorais
© © All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia on-line no Scribd
0% acharam este documento útil (0 voto)
23 visualizações8 páginas

Post em Blog

O documento descreve um fluxo de trabalho automatizado que busca notícias sobre tecnologia, filtra as novas com base em temas usados, gera um artigo sobre elas e envia um e-mail com o conteúdo gerado. Ele utiliza a API de notícias, Google Sheets para armazenar temas, e OpenAI para criar o artigo. O fluxo é acionado por um gatilho programado e envolve várias etapas de processamento e filtragem de dados.

Enviado por

Fabio Aragao
Direitos autorais
© © All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia on-line no Scribd

{

"name": "Post em Blog",


"nodes": [
{
"parameters": {
"url": "https://newsapi.org/v2/everything",
"options": {},
"headerParametersUi": {
"parameter": [
{
"name": "X-Api-Key",
"value": "910bf4f3e20e41a88badb8d4d1564a52"
}
]
},
"queryParametersUi": {
"parameter": [
{
"name": "q",
"value": "tecnologia"
},
{
"name": "sortBy",
"value": "popularity"
},
{
"name": "language",
"value": "pt"
},
{
"name": "pageSize",
"value": "2"
}
]
}
},
"id": "94521073-9064-4232-982d-f4d51e9e24a6",
"name": "Buscar Notícias",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
-260,
-80
]
},
{
"parameters": {
"documentId": {
"__rl": true,
"value": "1Y3bmX3i5s7FBHXT3I5qUZ7PeCX0-Skl-bQI0-1LFn4s",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "Página1",
"mode": "name"
},
"options": {}
},
"id": "30023085-fd93-4652-a1f5-6340f34ddeae",
"name": "Ler Temas Usados",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4,
"position": [
-60,
-220
],
"alwaysOutputData": true,
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"id": "Mj8JL66xO860i6Cn",
"name": "Google Sheets account"
}
}
},
{
"parameters": {
"functionCode": "// Código com fallback para quando a planilha estiver
vazia\nconst noticias = $json.articles || [];\n\n// Tentar ler temas usados, com
fallback para array vazio\nlet usados = [];\ntry {\n // Acessa a saída do nó 'Ler
Temas Usados' e mapeia para o campo 'Titulo'\n const temasUsados = $('Ler Temas
Usados').items || [];\n usados = temasUsados.map(item =>\n
item.json?.Titulo?.toLowerCase()\n ).filter(Boolean); // Remove quaisquer valores
nulos/undefined da lista\n} catch (error) {\n // Se não conseguir ler a planilha,
continua com array vazio\n usados = [];\n console.error(\"Erro ao ler temas
usados da planilha:\", error);\n}\n\n// --- LINHAS DE DEPURACÃO ADICIONADAS AQUI
---\nconsole.log('--- DEPURACAO: INICIO ---');\nconsole.log('Notícias recebidas
para filtro:', noticias.map(n => n.title));\nconsole.log('Temas usados (lidos da
planilha):', usados);\n// --- FIM DAS LINHAS DE DEPURACÃO ADICIONADAS ---\n\n//
Filtrar notícias novas\nconst novas = noticias.filter(n => {\n const isUsed =
usados.includes(n.title.toLowerCase());\n\n // --- LINHAS DE DEPURACÃO ADICIONADAS
AQUI ---\n console.log(`Verificando \"${n.title}\": É usado? ${isUsed}`);\n //
--- FIM DAS LINHAS DE DEPURACÃO ADICIONADAS ---\n\n return (\n n.title &&\n
n.description &&\n n.url &&\n !isUsed && // Verifica se o título (em
minúsculas) NÃO está na lista de usados\n n.title.length > 10 // Evitar títulos
muito curtos\n );\n});\n\n// --- LINHAS DE DEPURACÃO ADICIONADAS AQUI ---\
nconsole.log('Notícias filtradas (novas):', novas.map(n => n.title));\
nconsole.log('--- DEPURACAO: FIM ---');\n// --- FIM DAS LINHAS DE DEPURACÃO
ADICIONADAS ---\n\n// Retornar até 10 notícias por execução (para ter mais opções
de temas novos)\nreturn novas.slice(0, 10).map(n => ({\n json: {\n titulo:
n.title,\n descricao: n.description,\n url: n.url,\n fonte: n.source?.name
|| 'Não informado',\n dataPublicacao: n.publishedAt,\n imagem: n.urlToImage\n
}\n}));"
},
"id": "2a71a82a-2c77-4469-a246-b377049bddf3",
"name": "Filtrar Notícias Novas",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
140,
-80
],
"alwaysOutputData": true
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "1Y3bmX3i5s7FBHXT3I5qUZ7PeCX0-Skl-bQI0-1LFn4s",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Página1",
"cachedResultUrl":
"https://docs.google.com/spreadsheets/d/1Y3bmX3i5s7FBHXT3I5qUZ7PeCX0-Skl-bQI0-
1LFn4s/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Titulo": "={{ $('Filtrar Notícias Novas').item.json.titulo }}",
"Descricao": "={{ $('Filtrar Notícias Novas').item.json.descricao }}",
"DataPostagem": "={{ $('Filtrar Notícias
Novas').item.json.dataPublicacao }}"
},
"matchingColumns": [],
"schema": [
{
"id": "Titulo",
"displayName": "Titulo",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "URL",
"displayName": "URL",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Descricao",
"displayName": "Descricao",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "DataDescoberta",
"displayName": "DataDescoberta",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "DataPostagem",
"displayName": "DataPostagem",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"id": "daebe3e2-a934-407c-bb91-7118408911ab",
"name": "Salvar Tema Usado",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4,
"position": [
880,
-80
],
"credentials": {
"googleSheetsOAuth2Api": {
"id": "Mj8JL66xO860i6Cn",
"name": "Google Sheets account"
}
}
},
{
"parameters": {
"modelId": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "GPT-4O-MINI"
},
"messages": {
"values": [
{
"content": "=Escreva um artigo completo e profissional sobre
tecnologia em português brasileiro, baseado nas informações abaixo:\n\n**Título**:
{{$json[\"titulo\"]}}\n**Descrição**: {{$json[\"descricao\"]}}\n**URL da fonte**:
{{$json[\"url\"]}}\n\n**Instruções específicas:**\n1. Crie um artigo original de
300-500 palavras\n2. Use linguagem acessível mas profissional\n3. Estruture com:
introdução, desenvolvimento (2-3 seções), conclusão\n4. Inclua análise de impacto e
perspectivas futuras\n5. Adicione subtítulos descritivos\n6. Não copie conteúdo da
descrição, mas expanda o tema\n7. Mantenha tom neutro e informativo\n8. Inclua
call-to-action sutil no final\n\nFormato de saída:\n- Título principal (H1)\n-
Subtítulos (H2)\n- Parágrafos bem estruturados\n- Linguagem clara e envolvente"
}
]
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.8,
"position": [
340,
-80
],
"id": "0669610e-3caa-4d5a-9e98-40bcb8b670d8",
"name": "Message a model",
"credentials": {
"openAiApi": {
"id": "twtHlx054sFq6CVM",
"name": "OpenAi account 2"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 8
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-680,
-80
],
"id": "2cdfc688-3601-4775-842d-184ce462f171",
"name": "Schedule Trigger"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "b14f009e-3a77-4acd-a26e-fd252edba659",
"name": "=fromDate",
"value": "={ \"fromDate\": \"{{ (() => { const now = new
Date(); now.setDate(now.getDate() - 2); return now.toISOString().split('T')
[0]; })() }}\" }",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-480,
-80
],
"id": "0dc514c1-2cb1-4f12-90ab-a431c93661ef",
"name": "Edit Fields"
},
{
"parameters": {
"sendTo": "[email protected]",
"subject": "=Artigo Criado: {{ $('Filtrar Notícias
Novas').item.json.titulo }}",
"message": "={{ $json.message.content }}",
"options": {}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
700,
-80
],
"id": "3cec7f38-f677-4ff1-b994-9a0a531d667d",
"name": "Enviar Email",
"webhookId": "bfce7749-a9ca-4bb5-98f6-1edd883dff69",
"credentials": {
"gmailOAuth2": {
"id": "Mx4svzcz4VN9rQvH",
"name": "Gmail account"
}
}
}
],
"pinData": {},
"connections": {
"Buscar Notícias": {
"main": [
[
{
"node": "Ler Temas Usados",
"type": "main",
"index": 0
},
{
"node": "Filtrar Notícias Novas",
"type": "main",
"index": 0
}
]
]
},
"Ler Temas Usados": {
"main": [
[
{
"node": "Filtrar Notícias Novas",
"type": "main",
"index": 0
}
]
]
},
"Filtrar Notícias Novas": {
"main": [
[
{
"node": "Message a model",
"type": "main",
"index": 0
}
]
]
},
"Message a model": {
"main": [
[
{
"node": "Enviar Email",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Buscar Notícias",
"type": "main",
"index": 0
}
]
]
},
"Enviar Email": {
"main": [
[
{
"node": "Salvar Tema Usado",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "d20e61bb-44db-46b3-9b68-1eca08ecea6b",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId":
"8b7f23806e8fc7a952cef24bd6c6429cf14268d072188403f1e168f9e134f24d"
},
"id": "nQeBo7dy7zarp9lD",
"tags": []
}

Você também pode gostar