{
  "name": "Send Daily Wellness Tip to Telegram Group",
  "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": "ec3b45ca-7802-48df-861b-d280e9808ca1",
      "name": "Telegram",
      "webhookId": "bffcc35a-9a53-48ad-ab9d-af597a87dbd5",
      "credentials": {
        "telegramApi": {
          "id": "LXHr60rCVMuiROdo",
          "name": "Telegram account 2"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8,
              "triggerAtMinute": 1
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -880,
        60
      ],
      "id": "8cb17227-ca5b-4a4e-8bad-da714e129568",
      "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": "247c7924-8137-42a9-8f04-9d7d9f4c0e76",
      "name": "Random Tip"
    },
    {
      "parameters": {
        "base": {
          "__rl": true,
          "value": "apptiv4jVQxhXHZEd",
          "mode": "list",
          "cachedResultName": "Marketing Campaign Management",
          "cachedResultUrl": "https://airtable.com/apptiv4jVQxhXHZEd"
        },
        "table": {
          "__rl": true,
          "value": "tblOAOzMTxELl5Fv4",
          "mode": "list",
          "cachedResultName": "Wellness Tips",
          "cachedResultUrl": "https://airtable.com/apptiv4jVQxhXHZEd/tblOAOzMTxELl5Fv4"
        },
        "id": "=",
        "options": {}
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        -680,
        60
      ],
      "id": "ae1dbc75-f840-4af8-aad3-62ce045f798d",
      "name": "Get Wellness Tips from Airtable",
      "credentials": {
        "airtableTokenApi": {
          "id": "AOKcTd9LTmlwqbjP",
          "name": "Airtable Personal Access Token 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": "42dd16e8-bc05-4f4e-84b2-a506b23ed0da",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "fcb622cbd5234c565b9b78babeaf0ea2455df9d2aad0d1adff7c1ef99583e685"
  },
  "id": "dY15nxYck5hyr2Mt"
}