Multiple triggers

Each Inngest function can be triggered by one or more events or schedules, up to a maximum of 10.

This is useful for running the same logic for a wide array of events, or ensuring something also runs on a schedule, for example running an integrity check every morning, or when requested using an event.

inngest.createFunction(
  { id: "my-fn" },
  [
    { event: "a" },
    { event: "b" },
    { cron: "0 * * * *" },
  ],
  async ({ event, step }) => {
    // ...
  },
);

Determining event types

In the handler for a function with multiple triggers, the event that triggered the function can be determined using the event.name property.

async ({ event }) => {
  //      ^? type event: EventA | EventB | InngestScheduledEvent | InngestFnInvoked
  if (event.name === "a") {
    // `event` is type narrowed to only the `a` event
  } else if (event.name === "b") {
    // `event` is type narrowed to only the `b` event
  } else {
    // `event` is type narrowed to only the `inngest/function.invoked` event
  }
}

Note that batches of events can contain many different events; you will need to assert the shape of each event in a batch individually.

Overlapping crons

If your function defines multiple cron triggers, the schedules may sometimes overlap. For example, a cron 0 * * * * that runs every hour and a cron */30 * * * * that runs every half hour would overlap at the start of each hour.

Only one cron job will be run for each given second, so in this case above, one cron would run every half hour.