8
n8n 中文网amn8n.com

AI驱动的晨间俳句生成器(Google Docs + Gmail)

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 14 个节点。主要使用 Set, Code, Gmail, GoogleDocs, Agent 等节点。 使用OpenRouter AI、Google Docs和Gmail的每日晨间俳句生成

前置要求
  • Google 账号和 Gmail API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "sSq3OBOGly6oGT5M",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d"
  },
  "name": "AI 驱动的晨间俳句生成器(Google Docs + Gmail)",
  "tags": [],
  "nodes": [
    {
      "id": "c2c25ff3-8044-40c1-9a0f-08e469f42250",
      "name": "定时触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        16,
        144
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b86d8fbd-7154-43f0-a722-e22ca8ac170a",
      "name": "JavaScript 代码",
      "type": "n8n-nodes-base.code",
      "position": [
        592,
        144
      ],
      "parameters": {
        "jsCode": "// 前のAI Agentノードから出力を受け取ります。\n// データは 'output' フィールドに入っています。\nlet aiResponse = $node[\"AI Agent\"].json.output;\n\n// AIの応答に```json ... ```のような余分な文字が含まれている場合、\n// 中身のJSON部分だけを抽出します。\nif (aiResponse.includes('```')) {\n  aiResponse = aiResponse.substring(aiResponse.indexOf('{'), aiResponse.lastIndexOf('}') + 1);\n}\n\n// JSON文字列をオブジェクトに変換します。\nconst words = JSON.parse(aiResponse);\n\n// AIが生成した単語を使って、5-7-5調の俳句を組み立てます。\nconst line1 = `${words.kigo}の中`;\nconst line2 = `${words.noun}で心が${words.verb1}`;\nconst line3 = `今日もまた${words.verb2}`;\n\nconst haiku = `${line1}\\n${line2}\\n${line3}`;\n\n// タイトルを生成し、haikuと一緒に後続のノードへ渡します。\nconst title = `今日の一句 (${new Date().toLocaleDateString('ja-JP')})`; // ← ここのタイプミスを修正\n\nreturn [{\n  json: {\n    haiku,\n    title\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "8da62bb5-391d-40ad-a9e3-e8a50f3d2983",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        816,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "774b47ef-875a-4f9f-9530-51ae0720ae44",
              "name": "documentTitle",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "66d74b89-e9f5-4982-ae66-e5fb18b10993",
              "name": "documentBody",
              "type": "string",
              "value": "={{ \"# \" + $json.title + \"\\n\\n\" + $json.haiku + \"\\n\\n$2014 n8n Haiku Generator\" }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "f21266fa-3226-443f-a84d-a958497a5948",
      "name": "创建文档",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1040,
        144
      ],
      "parameters": {
        "title": "={{ $node[\"Edit Fields\"].json.documentTitle ?? '今日の一句' }}\n",
        "folderId": "1W45ugKiRbbwp3FIFdLL690DAgkVKCKWB"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "8gSL1GR6UbWI85jx",
          "name": "roumut.shukuwa@gmail.com"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "d9b2fbbb-341f-4d20-b493-c48e7c1e56d7",
      "name": "发送消息",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1712,
        144
      ],
      "webhookId": "2c597a75-2510-43b9-ba30-a50565f7784f",
      "parameters": {
        "sendTo": "syukuwa@joseikincenter.com",
        "message": "={{ $node[\"Code in JavaScript\"].json.haiku + \"\\n\\n$2014 本日の俳句をお届けします $2600$FE0F\" }}",
        "options": {},
        "subject": "={{ $node[\"Edit Fields\"].json.documentTitle }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "cj3AlN01rxKBC3Tg",
          "name": "roumut.shukuwa@gmail.com"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "745a8e10-7393-42e1-8d01-3808d5c0553a",
      "name": "准备追加",
      "type": "n8n-nodes-base.set",
      "position": [
        1264,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e4fc8729-a49f-42b4-a626-8e15ed84d7fc",
              "name": "docId",
              "type": "string",
              "value": "={{ $node[\"Create a document\"].json.id }}"
            },
            {
              "id": "469d4459-0ec7-4cbd-8bd7-f32853d7e3a8",
              "name": "text",
              "type": "string",
              "value": "={{ $node[\"Edit Fields\"].json.documentBody }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5f7c8ef7-bd1a-4987-a976-69924d084c33",
      "name": "更新文档",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1488,
        144
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $node[\"Prepare Append\"].json.text }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "={{ $node[\"Prepare Append\"].json.docId }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "8gSL1GR6UbWI85jx",
          "name": "roumut.shukuwa@gmail.com"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "c0b48c24-42be-45ca-959d-ef0d439b38cd",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        240,
        144
      ],
      "parameters": {
        "text": "あなたは創造的な俳人です。\n俳句を生成するための部品となる単語を4つ、JSON形式で提案してください。\n\n- kigo: 現在の季節に合った美しい季語を1つ\n- noun: 情景が浮かぶような名詞を1つ\n- verb1: 動作や状態を表す動詞を1つ\n- verb2: 1つ目の動詞とは異なる、余韻を残すような動詞をもう1つ\n\n説明や余計なテキストは一切含めず、必ず以下のJSON形式のフォーマットで、キーも英語で出力してください:\n{\n  \"kigo\": \"ここに季語\",\n  \"noun\": \"ここに名詞\",\n  \"verb1\": \"ここに動詞1\",\n  \"verb2\": \"ここに動詞2\"\n}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "a39e75bc-a06d-4dfd-a521-579a5bd34838",
      "name": "OpenRouter 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        312,
        368
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "fMR5QJezr3tD108w",
          "name": "簡易デモ"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b3378d42-0e19-4103-ad86-b0f67399a29d",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        -384
      ],
      "parameters": {
        "width": 400,
        "height": 512,
        "content": "## 概述:AI 驱动的晨间俳句生成器"
      },
      "typeVersion": 1
    },
    {
      "id": "a50e624c-29f3-4e4e-bed8-ac023a2b5e4b",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -112
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "### 第一部分 - 定时与 AI 生成"
      },
      "typeVersion": 1
    },
    {
      "id": "bf77288f-0b71-4552-898d-f21994175afd",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -112
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "### 第二部分 - 构建与格式化俳句"
      },
      "typeVersion": 1
    },
    {
      "id": "f45248f1-6075-4fd4-a782-403a2f55c323",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -112
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "### 第三部分 - Google Docs 自动化"
      },
      "typeVersion": 1
    },
    {
      "id": "79cf9fc1-7420-4e28-a6df-9b6ff0de685e",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        -112
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "### 第四部分 - 邮件发送"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c8750437-c566-4ffc-aad7-874169a5d914",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Create a document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Append": {
      "main": [
        [
          {
            "node": "Update a document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a document": {
      "main": [
        [
          {
            "node": "Prepare Append",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update a document": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流