Skip to main content
Prerequisites: An email address must be provisioned by Momentic.
Email runs inside the JavaScript step’s sandbox via the global email object. Momentic-provisioned inboxes end in @usemomentic.com or @gomomentic.com.

email.send

Send an email from a Momentic-provisioned address.
await email.send({
  subject: "Hello",
  body: "Hello world!",
  to: "[email protected]",
  from: "momentic", // Momentic-provisioned inbox name
});

email.fetchLatest

Returns the most recent email, polling until one arrives or the timeout elapses. Throws on timeout.
const msg = await email.fetchLatest({
  inbox: "jeff+test", // Momentic-provisioned inbox name
  afterDate: new Date(), // only fetch emails received after this date
  timeout: 20_000, // milliseconds, keep below the JS step timeout (default 10s)
  // trimWhitespace?: boolean  - default true
});

// msg.subject, msg.from, msg.fromEmail, msg.to, msg.time, msg.secondsAgo
// msg.size, msg.text, msg.html
return msg.text;

email.fetchAll

Returns up to limit emails without polling. Throws if the inbox is empty. Defaults: 15 minute window, 3 emails. Max: 24 hours, 10 emails.
const msgs = await email.fetchAll({
  inbox: "jeff+test",
  afterDate: new Date(Date.now() - 60 * 1000), // last 60 seconds
  limit: 5, // default 3, max 10
  // trimWhitespace?: boolean  - default true
});

return msgs.filter((msg) => msg.text.includes("verification code"));

Isolated inboxes

Append a suffix to your provisioned username to create unlimited isolated inboxes. If your username is momentic, [email protected] is a separate inbox fetched via inbox: "momentic+test". Use randomized suffixes (e.g. Date.now()) in parallel runs to avoid race conditions.