Use N8N AI agent for GLPI report
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
"assignments": [
|
||||
{"id": "data-alvo", "name": "data_alvo", "type": "string", "value": ""},
|
||||
{"id": "slack-webhook-url", "name": "slack_webhook_url", "type": "string", "value": "https://hooks.slack.com/services/SEU/WEBHOOK/AQUI"},
|
||||
{"id": "openai-api-key", "name": "openai_api_key", "type": "string", "value": "COLE_SUA_OPENAI_API_KEY_AQUI"},
|
||||
{"id": "openai-model", "name": "openai_model", "type": "string", "value": "gpt-5.5"}
|
||||
]
|
||||
},
|
||||
@@ -79,29 +78,39 @@
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://api.openai.com/v1/chat/completions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {"parameters": [{"name": "Content-Type", "value": "application/json"}, {"name": "Authorization", "value": "={{ 'Bearer ' + $('Config - Diario SQL').first().json.openai_api_key }}"}]},
|
||||
"sendBody": true,
|
||||
"contentType": "json",
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={{ { model: $('Config - Diario SQL').first().json.openai_model || 'gpt-5.5', messages: [ { role: 'system', content: 'Você é um analista de suporte. Gere um resumo curto em português do Brasil para Slack. Use somente os números fornecidos.' }, { role: 'user', content: 'Dados GLPI:\n' + JSON.stringify($json) + '\n\nExplique que fechados no período podem ter sido abertos em datas anteriores. Seja objetivo.' } ] } }}",
|
||||
"options": {}
|
||||
"promptType": "define",
|
||||
"text": "={{ $json.texto_base }}\n\nDados estruturados para analise:\n{{ JSON.stringify($json) }}",
|
||||
"options": {
|
||||
"systemMessage": "Voce e um agente coordenador de relatorios GLPI para Slack. Melhore o texto recebido sem inventar numeros. Destaque abertos, fechados, saldo, pendentes, alta prioridade, categorias e clientes. Se for semanal, trate como periodo semanal. Se for diario, trate como dia anterior. Explique de forma curta que chamados fechados no periodo podem ter sido abertos em datas anteriores. Responda apenas com a mensagem final para Slack em portugues do Brasil."
|
||||
}
|
||||
},
|
||||
"id": "openai-diario-sql",
|
||||
"name": "OpenAI - Gerar resumo",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"id": "ai-agent-coordenador-glpi",
|
||||
"name": "AI Agent - Coordenador GLPI",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"typeVersion": 1.7,
|
||||
"position": [1480, 300],
|
||||
"continueOnFail": true,
|
||||
"retryOnFail": true,
|
||||
"maxTries": 3,
|
||||
"waitBetweenTries": 30000
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst textoIa = data.choices?.[0]?.message?.content;\nconst fallback = $('Code - Preparar indicadores').first().json.texto_base;\n\nreturn [{ json: { text: textoIa || fallback } }];"
|
||||
"model": {
|
||||
"__rl": true,
|
||||
"value": "={{ $('Config - Diario SQL').first().json.openai_model || 'gpt-5.5' }}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "gpt-5.5"
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "z-ia-chat-model",
|
||||
"name": "Z IA Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1.2,
|
||||
"position": [1480, 520],
|
||||
"credentials": {"openAiApi": {"id": "", "name": "Z IA OpenAI"}}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst textoIa = data.output || data.text || data.response;\nconst fallback = $('Code - Preparar indicadores').first().json.texto_base;\n\nreturn [{ json: { text: textoIa || fallback } }];"
|
||||
},
|
||||
"id": "code-slack-diario",
|
||||
"name": "Code - Preparar mensagem Slack",
|
||||
@@ -133,8 +142,9 @@
|
||||
"Config - Diario SQL": {"main": [[{"node": "Code - Montar SQL diario", "type": "main", "index": 0}]]},
|
||||
"Code - Montar SQL diario": {"main": [[{"node": "MySQL - Indicadores diario GLPI", "type": "main", "index": 0}]]},
|
||||
"MySQL - Indicadores diario GLPI": {"main": [[{"node": "Code - Preparar indicadores", "type": "main", "index": 0}]]},
|
||||
"Code - Preparar indicadores": {"main": [[{"node": "OpenAI - Gerar resumo", "type": "main", "index": 0}]]},
|
||||
"OpenAI - Gerar resumo": {"main": [[{"node": "Code - Preparar mensagem Slack", "type": "main", "index": 0}]]},
|
||||
"Code - Preparar indicadores": {"main": [[{"node": "AI Agent - Coordenador GLPI", "type": "main", "index": 0}]]},
|
||||
"Z IA Chat Model": {"ai_languageModel": [[{"node": "AI Agent - Coordenador GLPI", "type": "ai_languageModel", "index": 0}]]},
|
||||
"AI Agent - Coordenador GLPI": {"main": [[{"node": "Code - Preparar mensagem Slack", "type": "main", "index": 0}]]},
|
||||
"Code - Preparar mensagem Slack": {"main": [[{"node": "HTTP - Slack enviar mensagem", "type": "main", "index": 0}]]}
|
||||
},
|
||||
"active": false,
|
||||
|
||||
Reference in New Issue
Block a user