8
n8n 中文网amn8n.com

使用 Cron 将每日肯定语发送到您的收件箱(可选 Telegram)

中级

这是一个Personal Productivity, Multimodal AI领域的自动化工作流,包含 8 个节点。主要使用 If, Set, Code, Cron, Telegram 等节点。 使用 Cron 定时发送每日肯定语到邮箱和 Telegram

前置要求
  • Telegram Bot Token
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "UN5orqkCo7Cpl3s1",
  "meta": {
    "instanceId": "8c8b20afd941aa66690830b5f1f0b9d7a4611a25b0382c8675a2fab2026ff320",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 Cron 将每日肯定语发送到您的收件箱(可选 Telegram)",
  "tags": [],
  "nodes": [
    {
      "id": "1c7b92ef-c3b8-456b-9732-2b2517bd0d33",
      "name": "README - 模板描述",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -160
      ],
      "parameters": {
        "width": 520,
        "height": 716,
        "content": "## 适用人群"
      },
      "typeVersion": 1
    },
    {
      "id": "1ccaa156-e893-402f-92c7-00650f3d502e",
      "name": "Cron:每天早上 7 点触发",
      "type": "n8n-nodes-base.cron",
      "position": [
        -368,
        272
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 7
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ee4ea726-e77b-4a5b-be2a-30a933fb584a",
      "name": "设置:配置(编辑我)",
      "type": "n8n-nodes-base.set",
      "position": [
        -48,
        272
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "fromEmail",
              "value": "sender@example.com"
            },
            {
              "name": "toEmail",
              "value": "recipient@example.com"
            },
            {
              "name": "subject",
              "value": "🌸 Morning Affirmation"
            },
            {
              "name": "telegramChatId"
            },
            {
              "name": "affirmations",
              "value": "I choose peace today.\nI am grounded, present, and safe.\nMy creativity flows with ease.\nI honor my rhythms and rest.\nI am worthy of beautiful systems.\nSmall steps create big shifts.\nI trust my inner wisdom.\nI am consistent and kind to myself.\nI make room for joy and spaciousness.\nI release what I can’t control."
            }
          ],
          "boolean": [
            {
              "name": "sendTelegram"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 2
    },
    {
      "id": "0e53b915-f601-4d59-ac2a-4407321d0579",
      "name": "代码:随机选择肯定语",
      "type": "n8n-nodes-base.code",
      "position": [
        256,
        272
      ],
      "parameters": {
        "jsCode": "// v2 syntax – must return an array of { json: {...} }\nconst lines = $json.affirmations\n  .split('\\n')\n  .map(s => s.trim())\n  .filter(Boolean);\n\nconst pick = lines.length\n  ? lines[Math.floor(Math.random() * lines.length)]\n  : 'I am enough.';\n\nreturn [{\n  json: {\n    ...$json,\n    affirmation: pick\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "df92af24-63f2-4f06-a2b5-c95efc770c43",
      "name": "IF:Telegram 启用了吗?",
      "type": "n8n-nodes-base.if",
      "position": [
        544,
        384
      ],
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$json.sendTelegram}}",
              "operation": "is true"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0e71dab6-50b7-4d69-a3f7-f1e859fe5071",
      "name": "邮件:发送肯定语",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        848,
        272
      ],
      "webhookId": "cc9a4979-35b0-45f3-883d-dad56ae10906",
      "parameters": {
        "text": "={{$json.affirmation}}",
        "options": {},
        "subject": "={{$json.subject}}",
        "toEmail": "={{$json.toEmail}}",
        "fromEmail": "={{ $json.fromEmail}}"
      },
      "credentials": {
        "smtp": {
          "id": "MX4srF0whebaDqig",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "a27509fc-57c0-4f17-8575-c15bda10b211",
      "name": "Telegram:发送肯定语",
      "type": "n8n-nodes-base.telegram",
      "position": [
        848,
        512
      ],
      "webhookId": "13b34521-c384-48d4-8ec0-48b8a94f8208",
      "parameters": {
        "text": "🌸 {{$json.affirmation}}",
        "chatId": "={{$json.telegramChatId}}",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "2b7e064e-bc38-4d89-bd5e-f3b99e858fe9",
      "name": "设置提示",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        592
      ],
      "parameters": {
        "width": 520,
        "height": 216,
        "content": "### 快速设置清单"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "27f28c5e-3146-4e5e-95dd-d4cb657326af",
  "connections": {
    "IF: Telegram Enabled?": {
      "main": [
        [
          {
            "node": "Telegram: Send Affirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron: Trigger Daily at 7 AM": {
      "main": [
        [
          {
            "node": "Set: Configuration (edit me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set: Configuration (edit me)": {
      "main": [
        [
          {
            "node": "Code: Pick Random Affirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Pick Random Affirmation": {
      "main": [
        [
          {
            "node": "Email: Send Affirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 个人效率, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量8
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流