โ† Integrations

No-code / CMS ยท JavaScript

Transit alerts on a schedule with a Pipedream Node.js step

Ingresses and retrograde stations are what an astrology community channel or newsletter announces. A Pipedream workflow can look ahead every day, find the events with one AstroNode call, and pass only the ones it has not announced yet to a Slack, Telegram or email step.

Updated

How this page was checked: Pipedream was not run. The step was executed on Node 24 against the in-memory API with defineComponent as an identity function and $.export, $.flow.exit and the data store stubbed - three times, with the clock set to 5 December 2026, the same moment again, and a week later. The outputs below are from those runs.

The workflow

  • Trigger: Schedule - daily, at a time in your audience's time zone (the schedule trigger takes a time zone).
  • Step `transits`: Node.js code - below.
  • Step: your messaging app - post each item of steps.transits.$return_value.

AstroNode has no Pipedream app, so there is no connected account to pick. Store the key as an environment variable ASTRONODE_API_KEY in your Pipedream settings and read it with process.env - it stays out of the step's code, out of exported workflow definitions, and out of the event inspector.

The step

js
const DAY = 86400000;

export default defineComponent({
  props: {
    seen: { type: "data_store" }, // remembers events already announced
  },
  async run({ steps, $ }) {
    const from = new Date(Date.now()).toISOString().slice(0, 10);
    const to = new Date(Date.now() + 14 * DAY).toISOString().slice(0, 10); // always later than from

    const res = await fetch(`${process.env.ASTRONODE_BASE_URL ?? "https://api.astronode.dev"}/v1/transits/events`, {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.ASTRONODE_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        from,
        to,
        planets: ["Sun", "Mercury", "Venus", "Mars", "Jupiter", "Saturn"],
        step_days: 0.25, // event times to the nearest 6 hours instead of the next midnight
      }),
    });
    const json = await res.json();
    if (!res.ok) throw new Error(`${res.status} ${json.error.code}: ${json.error.message}`);

    const fresh = [];
    for (const e of json.data.events) {
      const id = `${e.planet}:${e.kind}:${e.to_sign ?? e.sign}:${e.at.slice(0, 10)}`;
      if (await this.seen.get(id)) continue;
      await this.seen.set(id, e.at);
      fresh.push(e);
    }
    if (fresh.length === 0) return $.flow.exit("No new transit events");

    $.export("$summary", `${fresh.length} new transit event(s)`);
    return fresh.map((e) => ({
      when: e.at,
      text: e.kind === "sign_change" ? `${e.planet} enters ${e.to_sign}` : `${e.planet}: ${e.kind.replace("_", " ")}`,
    }));
  },
});

Pipedream fills the data_store prop with a key-value store you pick when you configure the step; it survives between runs, which is what lets a 14-day look-ahead run daily without repeating itself. $.flow.exit ends the workflow early, so the messaging step does not run on quiet days, and $summary is the line shown in the event list.

Three runs

Output of the step (times are UTC)
RunResult
5 Dec 20264 new: Mercury combust start (7 Dec 00:00), Saturn retrograde end (11 Dec 06:00), Jupiter retrograde start (13 Dec 06:00), Sun enters Sagittarius (16 Dec 06:00)
5 Dec again (a retry)No new transit events - all four were in the data store
12 Dec1 new: Mercury enters Sagittarius (22 Dec 06:00); the overlapping events were skipped

Each event has kind (sign_change, retrograde_start/_end, combust_start/_end, exalt_start...), the planet's sidereal longitude and sign, and for sign changes from_sign and to_sign. The scan is one call however long the window: a two-year range over all nine grahas returned 683 events. Background on the event kinds: retrograde and combustion.

How precise `at` is

The API samples planet positions every step_days and reports an event at the first sample after it happened. The default is one day, which is coarse for an announcement that names a time:

The Sun's move into Sagittarius in December 2026, by `step_days` (real responses)
step_daysat
1 (default)2026-12-17T00:00:00.000Z
0.252026-12-16T06:00:00.000Z
1/24 (hourly)2026-12-16T05:00:00.000Z

So the ingress fell between 04:00 and 05:00 UTC on the 16th; the daily default reported it the next midnight. A finer step is still one request. The step above uses six-hour sampling, which is enough to say "on the morning of the 16th" in India; use hourly if you print a clock time. Because from is always a UTC midnight, the sampling grid lines up from day to day and the de-duplication key stays stable.

The mistakes that bite first

  • Announcing everything every day. A look-ahead window overlaps yesterday's; without the data store, a two-week window announces each event up to fourteen times.
  • Lowercase planet names. "planets": ["sun"] returned 400 listing "Sun"|"Moon"|"Mars"|.... Planet names are capitalised, as in the responses.
  • A window that is not a window. to must be later than from; compute both from the same clock reading, as the step does, rather than from two different sources.
  • The plan. /v1/transits/events is a Hobby endpoint; a Free key fails the step with 403 PLAN_REQUIRED, which the thrown error puts in the run's log.

Questions

Which AstroNode endpoints does the Pipedream example call?
1 endpoint: Transit Events (Gochar) (POST /v1/transits/events).
Was the Pipedream code on this page actually run?
Pipedream was not run. The step was executed on Node 24 against the in-memory API with defineComponent as an identity function and $.export, $.flow.exit and the data store stubbed - three times, with the clock set to 5 December 2026, the same moment again, and a week later. The outputs below are from those runs.