{
  "name": "Daily Wellness Tip on Telegram",
  "nodes": [
    {
      "parameters": {
        "chatId": "-1002286661825",
        "text": "=🌟 ***Wellness Tip***🌟\n\n📝 ***Title***: {{ $json.Tip_Title }}\n\n💡***Tip***: {{ $json.Content }}\n\n✨ **Incorporate this tip into your daily routine for a healthier and happier life!** 💪🧘‍♂️🧘‍♀️\n🌱 **Take a step towards wellness today!** 🌈",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -300,
        60
      ],
      "id": "13dfb021-a8f7-4787-86bf-5f7d618ba02b",
      "name": "Telegram",
      "webhookId": "5e8e941c-4704-4451-97f7-cd1239f09ed2",
      "credentials": {
        "telegramApi": {
          "id": "rTvf4AlaFAFMFVQW",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8,
              "triggerAtMinute": 1
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -880,
        60
      ],
      "id": "415b1ab8-2832-4e4d-aa38-464781462b65",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "jsCode": "// Get the array of tips\nconst tips = $input.first().json.records;\n\n// Filter tips to only include those with Status \"pending\"\nconst pendingTips = tips.filter(tip => tip.fields['Status'] == 'pending');\n\n// Check if there are any unsent tips\nif (pendingTips.length === 0) {\n  throw new Error('No pending tips available.');\n}\n\n// Generate a random index from the pending tips\nconst randomIndex = Math.floor(Math.random() * pendingTips.length);\n\n// Retrieve the selected record\nconst randomTip = pendingTips[randomIndex];\n\n// Return the random unsent wellness tip\nreturn [{\n  json: {\n    Tip_Title: randomTip.fields['Tip Title'],\n    Content: randomTip.fields['Content'],\n    Category: randomTip.fields['Category'],\n    Date_Created: randomTip.fields['Date Created'],\n    Status: randomTip.fields['Status']\n  }\n}];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -480,
        60
      ],
      "id": "bc474c57-1c53-409e-9328-c6858c79180a",
      "name": "Random Tip"
    },
    {
      "parameters": {
        "base": {
          "__rl": true,
          "value": "apptiv4jVQxhXHZEd",
          "mode": "list",
          "cachedResultName": "Marketing Campaign Management"
        },
        "table": {
          "__rl": true,
          "value": "tblOAOzMTxELl5Fv4",
          "mode": "list",
          "cachedResultName": "Wellness Tips"
        },
        "id": "=",
        "options": {}
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        -680,
        60
      ],
      "id": "7f5ccb28-6a62-404c-b272-1ff29150f7b7",
      "name": "Get Wellness Tips from Airtable",
      "credentials": {
        "airtableTokenApi": {
          "id": "IHgJiuveAfFzvgv9",
          "name": "Airtable account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Wellness Tips from Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Random Tip": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Wellness Tips from Airtable": {
      "main": [
        [
          {
            "node": "Random Tip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "b790fa7a-ff6d-476e-9d4b-e9299bd6ca60",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f1c26778ec36097a9722a22c47c5e9c01f00b8862dadd0121ec118026a370fa6"
  },
  "id": "y3p9zwoPHfg2yFJU"
}