整合

Pipedream

從 Pipedream 的 Code step 跑 Thunderbit —— Node.js 或 Python 任你挑

Pipedream 是 Zapier 的開發者導向版本 —— 每條 workflow 就是一份你能直接編輯的真實腳本。要完整控制權就用 Code step,要免寫程式就用 HTTP / Webhook action。

Code step(Node.js)

import { defineComponent } from '@pipedream/core';

export default defineComponent({
  props: {
    thunderbit: { type: 'app', app: 'thunderbit' }, // or use an env var
    url:        { type: 'string' },
  },
  async run({ steps, $ }) {
    const res = await fetch(
      'https://openapi.thunderbit.com/openapi/v1/distill',
      {
        method: 'POST',
        headers: {
          Authorization: `Bearer ${process.env.THUNDERBIT_API_KEY}`,
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({ url: this.url, renderMode: 'basic' }),
      },
    );
    const json = await res.json();
    return json.data.markdown;
  },
});

Code step(Python)

import os, httpx

def handler(pd: "pipedream"):
    res = httpx.post(
        "https://openapi.thunderbit.com/openapi/v1/distill",
        headers={"Authorization": f"Bearer {os.environ['THUNDERBIT_API_KEY']}"},
        json={"url": pd.steps["trigger"]["event"]["url"], "renderMode": "basic"},
        timeout=60.0,
    )
    return res.json()["data"]["markdown"]

用 HTTP source 跑批次

要打 /batch/distill,在另一條 workflow 上掛 HTTP / Webhook source 當觸發器,再把 Thunderbit 的 callback.url 指到 Pipedream 給你的 source URL。批次完成時觸發器就會響 —— 下游步驟拿到的是完整的 results 陣列。

小技巧

  • 把 API Key 存成 Pipedream 的 Env Var(workspace 級或 workflow 級),別寫在程式碼裡
  • Pipedream 免費方案有單步運算上限 —— 在進下游 LLM 前先把 Markdown 修剪一下

相關文件