Skip to main content

Documentation Index

Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Prerequisite: A Momentic-provisioned phone number. Request one.

Single-number setup

If you only need OTP login from one fixed number (or your tests don’t run in parallel), fetch the latest message and pull the code out:
const msg = await sms.fetchLatest({
  to: "+18888888888",
  afterDate: new Date(Date.now() - 60_000),
  timeout: 30_000,
});

const [code] = msg.body.match(/\b\d{6}\b/) ?? [];
if (!code) throw new Error("No OTP code found in SMS");
setVariable("OTP_CODE", code);
Then add a Type step with value {{ env.OTP_CODE }}.

Parallel runs against the same OTP flow

If you run the same OTP login test in parallel (e.g. multiple shards in CI), two tests can race on the same inbound code. Lease a number from your pool so each shard gets its own. Momentic releases it back to the pool when the test finishes.
const { phoneNumber } = await sms.lease();

// trigger your app's "Send code" flow against `phoneNumber`

const msg = await sms.fetchLatest({
  to: phoneNumber,
  afterDate: new Date(Date.now() - 60_000),
  timeout: 30_000,
});

const [code] = msg.body.match(/\b\d{6}\b/) ?? [];
if (!code) throw new Error("No OTP code found in SMS");
setVariable("OTP_CODE", code);
See sms.lease() for full options (TTL, fail-fast, optional manual release).
Both examples poll for up to 30 seconds, so set the JavaScript step’s Timeout field to at least that. Steps default to 15 seconds (max 60) and will be killed early if the timeout is left at the default.