AutomationFlowsData & Sheets › Resumir chat post-stream con Groq y Postgres

Resumir chat post-stream con Groq y Postgres

Original n8n title: Resumen De Chat Post-stream

Resumen de Chat Post-Stream. Uses httpRequest, postgres. Webhook trigger; 5 nodes.

Webhook trigger★★★★☆ complexity5 nodesHTTP RequestPostgres
Data & Sheets Trigger: Webhook Nodes: 5 Complexity: ★★★★☆ Added:

This workflow follows the HTTP Request → Postgres recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Resumen de Chat Post-Stream",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "stream-ended",
        "responseMode": "responseNode"
      },
      "name": "Webhook: Stream Terminado",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        250,
        300
      ],
      "notes": "Llamar POST /webhook/stream-ended desde deploy.sh o manualmente cuando el stream termina"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "http://chat-bridge:4000/api/chat/history"
      },
      "name": "Obtener Historial Chat",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const messages = $input.first().json;\nconst chatLog = messages.map(m => `[${m.platform}] ${m.user}: ${m.text}`).join('\\n');\nconst totalMessages = messages.length;\nconst platforms = [...new Set(messages.map(m => m.platform))];\nconst gifts = messages.filter(m => m.type === 'gift');\nconst uniqueUsers = [...new Set(messages.map(m => m.user))];\n\nreturn [{\n  json: {\n    chatLog,\n    totalMessages,\n    platforms,\n    giftCount: gifts.length,\n    uniqueUsers: uniqueUsers.length,\n    topUsers: uniqueUsers.slice(0, 10),\n    summary_prompt: `Resume este chat de livestream en 3-5 puntos clave. Identifica los temas mas populares, preguntas frecuentes, y el sentimiento general:\\n\\n${chatLog}`\n  }\n}];"
      },
      "name": "Preparar Datos",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.groq.com/openai/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Bearer ' + $env.GROQ_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'llama-3.1-8b-instant', messages: [{ role: 'user', content: $json.summary_prompt }], stream: false }) }}"
      },
      "name": "Groq API: Resumir Chat",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        920,
        300
      ]
    },
    {
      "parameters": {
        "operation": "insert",
        "table": "stream_reports",
        "columns": "date,total_messages,unique_users,gift_count,summary,created_at",
        "values": "={{ $now.format('yyyy-MM-dd') }},={{ $('Preparar Datos').first().json.totalMessages }},={{ $('Preparar Datos').first().json.uniqueUsers }},={{ $('Preparar Datos').first().json.giftCount }},={{ $json.choices[0].message.content }},={{ $now.toISO() }}"
      },
      "name": "Guardar Reporte",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        1140,
        300
      ]
    }
  ],
  "connections": {
    "Webhook: Stream Terminado": {
      "main": [
        [
          {
            "node": "Obtener Historial Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Historial Chat": {
      "main": [
        [
          {
            "node": "Preparar Datos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preparar Datos": {
      "main": [
        [
          {
            "node": "Groq API: Resumir Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq API: Resumir Chat": {
      "main": [
        [
          {
            "node": "Guardar Reporte",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Mexico_City"
  },
  "tags": [
    {
      "name": "resumen"
    },
    {
      "name": "post-stream"
    }
  ]
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Resumen de Chat Post-Stream. Uses httpRequest, postgres. Webhook trigger; 5 nodes.

Source: https://github.com/Zolwayofficial/Influencer-IA/blob/b11438c70f772fcd5759e1e7aab317fb0dd4bf6f/n8n-workflows/04-chat-summary.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.

HTTP Request, Postgres, @Apify/N8N Nodes Apify
Data & Sheets

Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.

HTTP Request, Postgres, Error Trigger
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1