feat(flows):allineamento filtri

This commit is contained in:
2026-03-21 20:30:54 +00:00
parent 8394861bb3
commit 734a1a9440
14 changed files with 4186 additions and 144 deletions

View File

@@ -0,0 +1,135 @@
{
"id": "JJ6B3w8i1bL7Q0rr",
"name": "💬 Pompeo - Alexa Voice Interface [Webhook]",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "pompeo-alexa",
"responseMode": "lastNode",
"options": {}
},
"id": "n_wh",
"name": "Alexa Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
208,
304
],
"webhookId": "pompeo-alexa"
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT subject, category, pompeo_note FROM memory_facts WHERE user_id='martin' AND (expires_at IS NULL OR expires_at > now()) ORDER BY created_at DESC LIMIT 15",
"options": {}
},
"id": "n_memory",
"name": "Leggi Memoria",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.5,
"position": [
432,
304
],
"alwaysOutputData": true,
"credentials": {
"postgres": {
"id": "mRqzxhSboGscolqI",
"name": "Pompeo — PostgreSQL"
}
}
},
{
"parameters": {
"url": "https://api.github.com/copilot_internal/v2/token",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer ghu_WetWTL0IOKvvUPwZk6RGZ2qBnPd5Nz47qPXM"
},
{
"name": "editor-version",
"value": "vscode/1.95.3"
}
]
},
"options": {}
},
"id": "n_token",
"name": "Ottieni Token Copilot",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
640,
304
]
},
{
"parameters": {
"jsCode": "const webhookItem = $('Alexa Webhook').first().json;\nconst headers = webhookItem.headers || {};\nif ((headers['x-n8n-webhook-secret'] || '') !== 'cXvt0LZK9koIqgzcJZgV2qb4ymlEwpa7') {\n return [{ json: { tts_response: 'Accesso non autorizzato.' } }];\n}\nconst body = webhookItem.body || webhookItem;\nconst requestType = body.request?.type || 'Unknown';\nconst intent = body.request?.intent?.name || '';\nconst slots = body.request?.intent?.slots || {};\nconst query = Object.values(slots).map(s => s?.value).filter(Boolean).join(' ') || '';\n\nif (requestType === 'LaunchRequest') return [{ json: { tts_response: 'Ciao Martin! Sono Pompeo, il tuo assistente. Dimmi pure!' } }];\nif (requestType === 'SessionEndedRequest') return [{ json: { tts_response: '' } }];\nif (['AMAZON.StopIntent','AMAZON.CancelIntent'].includes(intent)) return [{ json: { tts_response: 'A presto Martin!' } }];\nif (intent === 'AMAZON.HelpIntent') return [{ json: { tts_response: 'Puoi chiedermi qualsiasi cosa. Cosa vuoi sapere?' } }];\n\nconst memoryFacts = $('Leggi Memoria').all().map(i => i.json).filter(f => f.subject);\nconst copilotToken = $('Ottieni Token Copilot').first().json.token;\nconst today = new Date().toLocaleDateString('it-IT', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });\nconst memCtx = memoryFacts.length > 0\n ? memoryFacts.map(f => `- [${f.category}] ${f.subject}${f.pompeo_note ? ' -> ' + f.pompeo_note : ''}`).join('\\n')\n : '(nessun fatto recente)';\n\nconst gptResp = await this.helpers.httpRequest({\n method: 'POST', url: 'https://api.githubcopilot.com/chat/completions',\n headers: { 'Authorization': `Bearer ${copilotToken}`, 'Content-Type': 'application/json',\n 'editor-version': 'vscode/1.95.3', 'Copilot-Integration-Id': 'vscode-chat' },\n body: JSON.stringify({ model: 'gpt-4.1', messages: [\n { role: 'system', content: `Sei Pompeo, l'assistente AI personale di Martin Tahiraj. Rispondi via Amazon Echo (testo letto ad alta voce). Regole: italiano, max 2-3 frasi concise, niente markdown o emoji, tono amichevole. Oggi: ${today}\\nContesto:\\n${memCtx}` },\n { role: 'user', content: query || 'dimmi qualcosa su di me' }\n ], temperature: 0.7, max_tokens: 200 })\n});\nconst content = gptResp.choices?.[0]?.message?.content || 'Non ho capito, puoi ripetere?';\nreturn [{ json: { tts_response: content.replace(/\\*\\*(.*?)\\*\\*/g,'$1').replace(/\\*(.*?)\\*/g,'$1').replace(/#{1,6}\\s/g,'').trim() } }];"
},
"id": "n_master",
"name": "Pompeo Core",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
864,
304
]
}
],
"connections": {
"Alexa Webhook": {
"main": [
[
{
"node": "Leggi Memoria",
"type": "main",
"index": 0
}
]
]
},
"Leggi Memoria": {
"main": [
[
{
"node": "Ottieni Token Copilot",
"type": "main",
"index": 0
}
]
]
},
"Ottieni Token Copilot": {
"main": [
[
{
"node": "Pompeo Core",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1",
"callerPolicy": "workflowsFromSameOwner",
"availableInMCP": false
},
"triggerCount": 1,
"versionId": "ea3ed67a-87ab-4289-8f53-c7e083e08087",
"owner": {
"type": "personal",
"projectId": "Hdttz401OqqtObPo",
"projectName": "Martin Tahiraj <tahiraj.martin@gmail.com>",
"personalEmail": "tahiraj.martin@gmail.com"
},
"parentFolderId": null,
"isArchived": false
}