{
  "name": "06 Weekly Google Trends report",
  "nodes": [
    {
      "parameters": {
        "content": "## Google Trends weekly report\nEvery Monday: interest and rising related searches for your keywords.\n\n1. Open **Config** and paste your Apify API token (free account: console.apify.com -> Settings -> API & Integrations).\n2. Paste a Discord/Slack webhook URL and/or a Telegram bot token + chat ID (delete the node you don't use).\n3. Click **Test workflow**, then switch it to **Active**.",
        "height": 340,
        "width": 420
      },
      "name": "How to use",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -400
      ],
      "id": "84d1faf0-771b-4ebd-bb69-ee5fd91af1a0"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * 1"
            }
          ]
        }
      },
      "name": "Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "71eebc99-d325-4f44-8e65-3fbebe17b0e5"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "344727dd-10fe-48a2-9ac5-b0ed608f6859",
              "name": "apifyToken",
              "value": "YOUR_APIFY_TOKEN",
              "type": "string"
            },
            {
              "id": "d683cc41-84b6-4e03-b685-0720ca5bce55",
              "name": "webhookUrl",
              "value": "https://discord.com/api/webhooks/...",
              "type": "string"
            },
            {
              "id": "e957f506-bdb5-451d-afe1-6fb9cbf31d93",
              "name": "telegramBotToken",
              "value": "",
              "type": "string"
            },
            {
              "id": "358242a6-99bd-49ca-991d-7e3c2556cafa",
              "name": "telegramChatId",
              "value": "",
              "type": "string"
            },
            {
              "id": "11aa717c-cc73-42c2-8db0-eac9b4bfd538",
              "name": "keywords",
              "value": "ai agents, n8n, web scraping",
              "type": "string"
            },
            {
              "id": "560cd439-e5fb-4e78-9a1c-dc9fc69bd056",
              "name": "geo",
              "value": "US",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "id": "ad44c051-c959-46af-9f13-9b94d45269fe"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.apify.com/v2/acts/martin10291~google-trends-explorer/run-sync-get-dataset-items",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "token",
              "value": "={{ $('Config').item.json.apifyToken }}"
            },
            {
              "name": "timeout",
              "value": "280"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({keywords: $('Config').item.json.keywords.split(',').map(s => s.trim()), geos: [$('Config').item.json.geo], timeframe: 'past_90_days', includeRelated: true, includeRegions: false}) }}",
        "options": {
          "timeout": 300000
        }
      },
      "name": "Run Apify scraper",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "id": "9eb27a23-f950-4472-925a-ac35284bb7fe"
    },
    {
      "parameters": {
        "jsCode": "const rows = $input.all();\nif (!rows.length) return [];\nconst text = 'Google Trends weekly:\\n' + rows.slice(0, 20).map(i => `• ${i.json.keyword || i.json.searchTerm}: interest ${i.json.averageInterest}, change ${i.json.changePercent}%`).join('\\n');\nreturn [{ json: { text } }];"
      },
      "name": "Format message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ],
      "id": "07209f42-9217-4c1e-87c2-60c93c8ae7cf"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Config').item.json.webhookUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({content: $json.text, text: $json.text}) }}",
        "options": {}
      },
      "name": "Send to Discord or Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        0
      ],
      "id": "e9848609-1f7a-4b9b-a934-8be35478d33d"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $('Config').item.json.telegramBotToken }}/sendMessage",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({chat_id: $('Config').item.json.telegramChatId, text: $json.text, disable_web_page_preview: true}) }}",
        "options": {}
      },
      "name": "Send to Telegram",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        200
      ],
      "id": "5f550cc0-593e-43af-9651-a90bfb4aacbd"
    }
  ],
  "connections": {
    "Schedule": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Run Apify scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Apify scraper": {
      "main": [
        [
          {
            "node": "Format message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format message": {
      "main": [
        [
          {
            "node": "Send to Discord or Slack",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "active": false
}