Skip to main content
Prerequisites: An SMS number must be provisioned by Momentic.
SMS runs inside the JavaScript step’s sandbox via the global sms object.

sms.send

Send an SMS from a Momentic-provisioned number.
await sms.send({
  body: "Hello world!",
  to: "+14151234567",
  from: "+14159876543", // Momentic-provisioned number
});

sms.fetchLatest

Returns the most recent message, polling until one arrives or the timeout elapses. Throws on timeout.
const { body } = await sms.fetchLatest({
  to: "+14151234567",
  from: "+14159876543", // optional, filters by sender
  afterDate: new Date(), // only fetch messages received after this date
  timeout: 30_000, // milliseconds
  // beforeDate?: Date
});

const link = body.match(/https?:\/\/[^\s]+/)[0];
return link;
Without afterDate, fetchLatest may return stale messages from previous runs. Keep tests single-flow per number to avoid race conditions.