# Pipedream接入 Server酱：Pipedream 工作流的任意触发事件推送到微信（2026 教程）

> 在 Pipedream 工作流中通过 Node.js 代码步骤调用 Server酱 API，将任意触发事件推送到微信。包含配置步骤与代码示例。

- 网页版：https://sct.ftqq.com/docs/integrations/pipedream/
- 更新日期：2026-07-17

# Pipedream + Server酱：工作流触发事件推送到微信

> 效果：Pipedream 工作流被触发时，自动将事件数据推送到微信

## 前置条件

- 获取 Server酱 SendKey（[30 秒获取教程](https://sct.ftqq.com/docs/getting-started/sendkey/)）
- 拥有 Pipedream 账号及一个已创建的工作流

## 配置步骤

1. 在 Pipedream 的环境变量/Secrets 设置中，添加一个变量，名称设为 `SERVERCHAN_SENDKEY`，值为你的 SendKey。不要将 SendKey 硬编码在代码中。

2. 在你的 Pipedream 工作流中，按需选择触发器，然后添加一个 **Node.js 代码步骤**。

3. 在代码步骤中粘贴以下代码，使用 `fetch` 向 Server酱 API 发送 POST 请求：

```javascript
export default defineComponent({
  async run({ steps, $ }) {
    const sendKey = process.env.SERVERCHAN_SENDKEY;
    // 从前序步骤提取数据拼 title/desp
    const title = steps.trigger.event.body?.subject || "Pipedream 触发通知";
    const desp = `触发事件数据：\n\n${JSON.stringify(steps.trigger.event, null, 2)}`;

    await fetch(`https://sctapi.ftqq.com/${sendKey}.send`, {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      body: new URLSearchParams({ title, desp }),
    });
  },
})
```

4. 部署并测试工作流。Server酱 支持推送到微信服务号/企业微信/钉钉/飞书等多个通道，详见 /getting-started/channels/。

## 完整示例

以下是一个包含错误处理与返回值校验的完整 Node.js 代码步骤示例，将前序步骤的具体数据拼接为 Markdown 正文：

```javascript
export default defineComponent({
  async run({ steps, $ }) {
    const sendKey = process.env.SERVERCHAN_SENDKEY;
    const event = steps.trigger.event;

    const title = `新事件：${event.body?.name || event.type}`;
    const desp = `### 事件详情\n\n- 触发时间：${event.ts}\n- 数据内容：${event.body?.message || '无'}`;

    const resp = await fetch(`https://sctapi.ftqq.com/${sendKey}.send`, {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      body: new URLSearchParams({ title, desp }),
    });

    const result = await resp.json();
    if (result.code !== 0) {
      throw new Error(`推送失败: ${result.message}`);
    }
    return result;
  },
})
```

如果你的 SendKey 以 `sctp` 开头，API 端点需改为 `https://你的UID.push.ft07.com/send/${sendKey}.send`，其中 UID 取自 sctp 后的数字。

## 常见问题

**Server酱的发送额度是多少？**
免费用户每天可发送 5 条，每分钟上限 50 条。订阅会员目前特价最低 3 元/月，一天最多可发 1000 条（[价格详情](https://sct.ftqq.com/subscribe)）。

**工作流执行成功但微信没收到消息？**
请先检查 Pipedream 代码步骤的运行日志，确认 HTTP 请求返回的 `code` 是否为 `0`。如果返回成功但未收到，请参考[常见问题与排查](https://sct.ftqq.com/docs/getting-started/faq/)。

**如何控制消息推送频率？**
可以在 Pipedream 工作流的触发器中设置过滤条件，或在代码步骤中加入节流逻辑，避免触发 Server酱 的每分钟 50 条限制。

## 相关集成

- [/integrations/python/](https://sct.ftqq.com/docs/integrations/python/) —— Python 脚本推送
- [/integrations/qinglong/](https://sct.ftqq.com/docs/integrations/qinglong/) —— 青龙面板任务通知
- [/integrations/uptime-kuma/](https://sct.ftqq.com/docs/integrations/uptime-kuma/) —— Uptime Kuma 宕机告警


## 懒人方案：把这段话复制给你的 AI 助手

把下面这段文字原样粘贴给 Claude Code、Cursor 或任何 AI 编程助手，它就会替你完成 Server酱 的接入：

```text
请帮我把 Server酱 微信通知接入到我当前的项目/工具中：
1. API：POST https://sctapi.ftqq.com/{SendKey}.send，参数 title（必填，不能含换行）、desp（正文，支持 Markdown，可选）；成功时返回 JSON 的 code 为 0。
2. 如果我的 SendKey 以 sctp 开头，则改用 https://{uid}.push.ft07.com/send/{SendKey}.send，uid 是 SendKey 中 sctp 与 t 之间的数字。
3. SendKey 从环境变量 SERVERCHAN_SENDKEY 读取；如果没有，提醒我到 https://sct.ftqq.com 免费获取（每天 5 条额度）。
4. 安全要求：不要把 SendKey 硬编码进代码、不要打印到日志、不要提交到 git。
5. 频率约定：任务结束发 1 条结果摘要即可，批量任务合并成一条，不要每步都推。
请根据我当前的项目和场景直接写好代码/配置并验证。
```

