A phone number for the text messages of your tests
An SMS inbox is the box made to receive the text messages sent to a phone number Facteur gives you, with their text and their extracted verification code.
// Your SMS inbox's number, copied from the application.
const number = process.env.FACTEUR_SMS_NUMBER;
const auth = { authorization: 'Bearer ' + process.env.FACTEUR_API_KEY };
// Same search as for email, sent again every second.
const since = new Date().toISOString();
await page.getByLabel('Phone').fill(number);
await page.getByRole('button', { name: 'Send me a code' }).click();
const search = new URLSearchParams({ inbox: 'k7p2w9qd', type: 'sms', since });
let messages = [];
for (let attempt = 0; attempt < 60 && messages.length === 0; attempt++) {
if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, 1000));
({ messages = [] } = await (await fetch('https://api.facteur.eu/messages?' + search, { headers: auth })).json());
}
expect(messages[0].otp).toBe('482913'); // already extracted
await page.getByLabel('Code received').fill(messages[0].otp);
Three steps to get a number, one of them on our side
-
Step 01
Create an SMS inbox
When you create an inbox, you pick the SMS channel. An SMS inbox has no email address and keeps no email.
-
Step 02
Ask for a number
In the inbox, you write a note for the team, for example "receive the verification codes of the staging environment". One request at a time per inbox. You can withdraw it until the number is assigned, whether it still waits for the team's answer or has already been accepted.
-
Step 03
Use it in your test
The team reviews the request and answers you in the application and by email. The number then shows in the inbox, with a button to copy it.
What you can do today
Each line describes today's state.
Asking for a number
The request, the team's answer and the assignment of the number work.
Receiving text messages
Once the number is assigned, every text message sent to it arrives in the inbox, with its text and its extracted verification code.
Countries open
Only one country is open for now. The request screen names it.
Depends on the plan
The Free plan allows no number. From the Solo plan, each plan sets how many numbers you may hold, and each one has its own price, on top of the plan. You see that number in the billing settings of the application, and the price of a number in the inbox, before you ask for it.
What you will read in the inbox
The sender and the text
Each text message is recorded with the number of its sender, the number that received it and its text.
The verification code
message.otpFacteur extracts the code from the text, as it does for an email. The values you defined on the inbox are extracted too.
The same reading as email
GET /messages?type=smsThe message search accepts the SMS channel. A test reads a text message the way it reads an email.
One message, one row
When the carrier delivers the same text message twice, Facteur keeps one.
Start with email
The trial without an account works today for emails. Text messages follow the same principle: a message arrives, the test reads it.