8
n8n 中文网amn8n.com

Slack+Bitly URL 生成器

高级

这是一个Social Media, AI Chatbot领域的自动化工作流,包含 19 个节点。主要使用 If, Slack, BitlyTool, GoogleSheets, SlackTrigger 等节点。 使用 GPT-4o-mini 和 Google Sheets 日志记录从 Slack 生成带 UTM 标签的 Bitly 链接

前置要求
  • Slack Bot Token 或 Webhook URL
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "lA4rExuNmuRPablT",
  "meta": {
    "instanceId": "16d5a69b6a4f4733c8f669903729902650204c895b060993271b9227d7b0b3e8",
    "templateCredsSetupCompleted": true
  },
  "name": "Slack+Bitly URL 生成器",
  "tags": [],
  "nodes": [
    {
      "id": "b2e9fe85-89de-4a63-8d2e-e9fda55abd84",
      "name": "Slack 触发器",
      "type": "n8n-nodes-base.slackTrigger",
      "position": [
        -500,
        -20
      ],
      "parameters": {
        "options": {
          "resolveIds": true
        },
        "trigger": [
          "app_mention"
        ],
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "[REDACTED]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ecf35ac1-0495-48fe-b1b6-17b3b4750ab6",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -160,
        -20
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are a bitly URL creator agent. Your job is to:\n1. Extract, infer and categorize *accurately*:\na. Target URL (The URL that the user wants to be shortened with Bitly)\nb. utm_source\nc. utm_medium\nd. utm_campaign\ne. utm_term (only when applicable)\nf. utm_content (only when applicable)\n\n2. After inferring the relevant information, you will need to standardize it such that it follows the utm naming best practices, namely:\n- The utm naming should all be in lower case and connected with underscore _ if it's more than one word, e.g: christmas_day\n- You might get user input in short form, example \"IG\" or \"LI\" or \"fb\" and these should all be converted to \"instagram\", \"linkedin\", \"facebook\", instead of \"facebook.com\"\n- for utm_medium, choose from the following list: social, community, labs, video, cpc, email, referral, organic, banner, affiliate, tools\n\n3. When you have all the information, create a Bitly Shortened Link using the Bitly Tool\n\nAsk questions where necessary to obtain the full information. Do not make up facts/hallucinate, prioritize accuracy in your inference.\n\nOn successful Bitly Link creation, an ideal response format would be:\n\"Here is your shortened Bitly link for the URL:\n[Insert Generated Bitly URL Link]\nThis link includes the following UTM parameters:\n- Target URL: (Insert the original Target URL)\n- utm_source: (Insert utm_source)\n- utm_medium: (Insert utm_medium)\n- utm_campaign: (Insert utm_campaign)\n- utm_term: (Insert utm_term if applicable, if not insert \"empty\")\n- utm_content: (Insert utm_content if applicable, if not insert \"empty\")"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "75abb766-85fb-440b-87d5-102af89b626a",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -220,
        200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "6c85565a-30d6-4259-9976-ac7b42bf327d",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -60,
        200
      ],
      "parameters": {
        "sessionKey": "={{ $('Slack Trigger').item.json.channel }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "e7f9c4d6-dcee-49ea-b36e-bf66ecf387f2",
      "name": "Bitly",
      "type": "n8n-nodes-base.bitlyTool",
      "position": [
        60,
        200
      ],
      "parameters": {
        "longUrl": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Long_URL', ``, 'string') }}",
        "additionalFields": {
          "domain": "[REDACTED]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5c28ce3e-740d-496c-a8bd-0d31c43d03a5",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1280,
        -20
      ],
      "parameters": {
        "columns": {
          "value": {
            "URL": "={{ $json.output['Target URL'] }}",
            "Date": "={{ $today }}",
            "Notes": "Executed by n8n workflow",
            "Owner": "={{ $json.output.User }}",
            "Status": "Done",
            "UTM ID": "={{ $json.output.utm_campaign }}",
            "UTM Term": "={{ $json.output.utm_term }}",
            "Bitly URL": "={{ $json.output['Bitly URL Link'] }}",
            "UTM Medium": "={{ $json.output.utm_medium }}",
            "UTM Source": "={{ $json.output.utm_source }}",
            "UTM Content": "={{ $json.output.utm_content }}",
            "UTM Campaign": "={{ $json.output.utm_campaign }}",
            "Title on Bitly (Campaign)": "={{ $json.output.utm_campaign }}"
          },
          "schema": [
            {
              "id": "URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Title on Bitly (Campaign)",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Title on Bitly (Campaign)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "UTM Source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "UTM Source",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "UTM Medium",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "UTM Medium",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "UTM Campaign",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "UTM Campaign",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "UTM Term",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "UTM Term",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "UTM Content",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "UTM Content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Owner",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Owner",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Bitly URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Bitly URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Notes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Notes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "UTM ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "UTM ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "[REDACTED]/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "[REDACTED]"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a08c2e8b-f14d-435e-9c32-94c116ec0859",
      "name": "信息提取器",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        640,
        -20
      ],
      "parameters": {
        "text": "={{ $('Slack Response').item.json.message.text }}",
        "options": {},
        "attributes": {
          "attributes": [
            {
              "name": "Bitly URL Link",
              "description": "Bitly URL Link Generated, usually right after \"Here is your shortened Bitly link for the URL:\""
            },
            {
              "name": "utm_campaign",
              "required": true,
              "description": "utm_campaign name"
            },
            {
              "name": "utm_source",
              "required": true,
              "description": "utm_source name"
            },
            {
              "name": "utm_medium",
              "required": true,
              "description": "utm_medium name"
            },
            {
              "name": "utm_term",
              "required": true,
              "description": "utm_term name"
            },
            {
              "name": "utm_content",
              "required": true,
              "description": "utm_content name"
            },
            {
              "name": "Target URL",
              "required": true,
              "description": "Original Target URL Link"
            },
            {
              "name": "User",
              "required": true,
              "description": "={{ $json.real_name }}"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "65622ec6-62ee-4b78-9aba-adf822d21053",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        680,
        220
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "2eba9bbb-6f16-4599-8123-4e4ae8e822de",
      "name": "Slack - 获取用户名",
      "type": "n8n-nodes-base.slack",
      "position": [
        460,
        -20
      ],
      "parameters": {
        "user": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Slack Trigger').item.json.user }}"
        },
        "resource": "user",
        "operation": "getProfile"
      },
      "typeVersion": 2.3
    },
    {
      "id": "637b896a-7343-44cd-842b-868938d2ea6c",
      "name": "Slack 响应",
      "type": "n8n-nodes-base.slack",
      "position": [
        280,
        -20
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "[REDACTED]"
        },
        "otherOptions": {
          "thread_ts": {
            "replyValues": {
              "thread_ts": "={{ $('Slack Trigger').item.json.ts }}"
            }
          },
          "includeLinkToWorkflow": false
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "000f70ec-b076-4cd9-9ce1-9e0bebe5ebe4",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        1000,
        -20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fa53297e-b196-4e52-a4dd-8843d2e7dd55",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.output['Bitly URL Link'] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "802cc2e4-0cce-49e4-b0f8-dd8bd9a145de",
      "name": "停止并报错",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        1280,
        160
      ],
      "parameters": {
        "errorMessage": "Workflow has stopped intentionally because Bitly URL Link does not exist or not generated"
      },
      "typeVersion": 1
    },
    {
      "id": "1a960b7a-9919-40f1-b3dc-9856a71d8f9a",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1180,
        -220
      ],
      "parameters": {
        "width": 340,
        "height": 760,
        "content": "更新日志"
      },
      "typeVersion": 1
    },
    {
      "id": "80e31a88-409e-4b31-a9b4-931f0abc1f67",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        940,
        -220
      ],
      "parameters": {
        "width": 220,
        "height": 760,
        "content": "If 节点"
      },
      "typeVersion": 1
    },
    {
      "id": "67d49e4c-ca9d-4d3e-8a63-7e2800fe0ede",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -220
      ],
      "parameters": {
        "width": 300,
        "height": 760,
        "content": "信息提取器"
      },
      "typeVersion": 1
    },
    {
      "id": "06e5401c-1f90-47a6-ab53-96419dc90ecf",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -220
      ],
      "parameters": {
        "width": 360,
        "height": 760,
        "content": "Slack 响应和获取用户名"
      },
      "typeVersion": 1
    },
    {
      "id": "9b178240-66da-4896-aa40-ae76dc9c4ffa",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -580,
        -220
      ],
      "parameters": {
        "width": 280,
        "height": 760,
        "content": "Slack 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "78381b0c-2fab-4912-9995-f54a93b60e86",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -220
      ],
      "parameters": {
        "width": 500,
        "height": 760,
        "content": "Bitly AI Agent"
      },
      "typeVersion": 1
    },
    {
      "id": "2dd5433a-8a46-4e6c-80c2-cc3823972d91",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1440,
        -220
      ],
      "parameters": {
        "width": 820,
        "height": 1320,
        "content": "🔗 Slack + Bitly UTM 生成器 — 由 OpenAI 驱动"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "723ac1de-6498-4074-98a5-d9e325835454",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop and Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bitly": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Slack Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Slack Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Response": {
      "main": [
        [
          {
            "node": "Slack - Get User Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack - Get User Name": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 社交媒体, AI 聊天机器人

需要付费吗?

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

工作流信息
难度等级
高级
节点数量19
分类2
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Automate With Marc

Automate With Marc

@marconi

Automating Start-Up and Business processes. Helping non-techies understand and leverage Agentic AI with easy to understand step-by-step tutorials. Check out my educational content: https://www.youtube.com/@Automatewithmarc

外部链接
在 n8n.io 查看

分享此工作流