Sending events from functions step.sendEvent()

Use to send event(s) reliability within your function. Use this instead of inngest.send() to ensure reliable event delivery from within functions. This is especially useful when creating functions that fan-out.

export default inngest.createFunction(
  { name: "User onboarding" },
  { event: "app/user.signup" },
  async ({ event, step }) => {
    // Do something
    await step.sendEvent({
      name: "app/user.activated",
      data: { userId: event.data.userId }
    });
    // Do something else
  }
);

To send events from outside of the context of a function, use inngest.send().


step.sendEvent(eventPayload | eventPayload[]): Promise

// Send a single event
await step.sendEvent({
  name: "app/user.activated",
  data: { userId: "01H08SEAXBJFJNGTTZ5TAWB0BD" }
})

// Send an array of events
await step.sendEvent([
  {
    name: "app/invoice.created",
    data: { invoiceId: "645e9e024befa68763f5b500" }
  },
  {
    name: "app/invoice.created",
    data: { invoiceId: "645e9e08f29fb563c972b1f7" }
  },
])

step.sendEvent() must be called using await or some other Promise handler to ensure your function sleeps correctly.