When you run an automation on an app, the login works perfectly fine, but the moment the app sends an OTP to your registered number, your agent stops.
But that's not a bug in your setup. OTPs exist to prove that a person with a specific device or inbox is present.
But you still need to test signup flows, run agents on accounts you own, and keep monitoring jobs alive overnight. So let's look at why OTP is so annoying, and the four ways teams actually get past it without doing anything shady.
Why OTP is hard to automate
There are a few separate problems:
- The code lives somewhere else. It's in an SMS on a phone, an email inbox, or an authenticator app. Your script is in a container. Getting the code from there to here is the whole challenge.
- It expires fast. A standard TOTP code rotates every 30 seconds by default (RFC 6238). SMS codes often expire within minutes.
- Delivery isn't instant or guaranteed. SMS goes through carriers, and arrival time varies and retries trigger rate limits.
- Services filter the number you use. Fraud teams don't trust virtual numbers. Twilio even publishes a guide on filtering out VoIP numbers before sending an OTP. So the cheap SMS API number you bought may never get the code at all.
- SMS itself is on its way out. NIST's SP 800-63B-4 treats SMS and voice codes as a restricted authenticator. More apps are moving to TOTP, passkeys and push prompts, which are even harder for a script to reach.

We've mentioned some solution below to tackle this OTP issue.
Way 1: turn it off in test (when it's your app)
If you own the app, the cleanest answer is not to send real codes in test at all.
Most auth providers support this. Firebase, for example, lets you register up to 10 fictional phone numbers with fixed codes. No SMS is sent, you don't burn quota, and it works on an emulator without Google Play services.
Way 2: own the secret (TOTP)
If the account uses an authenticator app, the code is just math on a shared secret and the clock. When you set up 2FA, the QR code contains that secret. Save it (in a secrets manager, not a repo) and you can generate codes yourself:
This is by far the most reliable option when it's available.
If an AI agent is doing the login, you don't want the secret sitting in a prompt. Mobilerun's Credentials can store a two-factor secret per app, and the value is injected into the field without ever appearing in the agent's context.
This approach is good for accounts you control that support authenticator apps. But make sure to watch out for consumer apps as some of them still only offer SMS.
Way 3: read the inbox with an API
When the code comes by email or SMS, you can give the automation its own inbox or number and read it programmatically.
For email this works well. You use a dedicated mailbox, poll it after triggering the code, and pull the digits out. Mobilerun mailboxes have an endpoint that returns the most likely recent code, so you skip the regex.
For SMS, the same idea works with an SMS API number. This is where it gets shaky, though. Many apps check the number type, and if yours comes back as VoIP, the code is never sent. You'll see it as "SMS not received".
Good for: email OTP, internal tools, services that accept virtual numbers. Watch out for: SMS to virtual numbers gets filtered by a lot of consumer apps and banks.
Way 4: use a real phone with a real SIM
When the service only trusts real mobile numbers, the answer is a real phone with a real mobile number. The SMS arrives the way it does for any user. Then you have two ways to get it.
Option A, the agent reads it on the phone. A mobile agent can switch apps like you do: open Messages, read the latest code, go back, type it in. With Mobilerun the whole thing is one plain-language goal: "Open the Acme app and sign in with my number. When it asks for a code, open Messages, read the newest code from Acme, switch back and enter it."
Option B, your backend reads it. Numbers on Mobilerun devices expose inbound SMS over the API, and you can subscribe to an sms.received webhook instead of polling.
Good for: consumer apps, banks, messaging apps, anything that rejects virtual numbers. Watch out for: it costs more than a virtual number, and it only makes sense for accounts you actually own and operate.
One detail that catches teams out: a data-only eSIM won't receive SMS. The line needs a real mobile number attached. We'll cover that trap in its own post.
Which one should you pick?
Approach | Reliability | cost | works on apps you don't own | Tests real delivery |
|---|---|---|---|---|
1. Test numbers / fixed codes | Very high | Free | No | No |
2. TOTP secret | Very high | Free | Yes, if the app offers TOTP | NA |
3. Inbox or SMS API | High for emails, mixed for SMS | Low | Sometimes | Partly |
4. Real phone, real SIM | High | Higher | Yes | Yes |
A simple rule: use 1 in CI for your own app, 2 wherever the app supports it, 3 for email codes, and 4 when the app only trusts a real mobile number.

A worked example
Say a team runs a nightly agent that checks payouts in a marketplace seller app for their own shop. The app logs out every few days and asks for an SMS code. Their VoIP number never receives anything.
They move the account onto a real phone with a real number. The agent goal becomes: "Open the seller app. If asked for a code, read it from Messages and enter it. Then report this week's payouts." The login step goes from "fails every few days" to "handled inside the same run", and the report lands every morning.
Nothing clever. The code just arrived where a code would normally arrive.
The honest part
OTP exists to protect accounts. Everything here is about automating accounts and apps you own or are allowed to test. Mass account creation and getting around someone else's verification are a different thing, and no tool should help with that.
Also, keep a human fallback. Even the best setup sometimes gets a code that doesn't arrive, and a "ping me on Slack to type the code" step is better than a silent failure.
Frequently Asked Questions
Why doesn't my SMS API number get the code?
Usually the service looks up the number type and refuses to send to VoIP numbers. Try a real mobile number on a real SIM.
Is TOTP better than SMS for automation?
Yes. If you have the secret, codes are generated locally with no delivery delay. It's also the more secure option for the account.
Can an AI agent read an SMS code by itself?
On a real phone, yes. It opens the Messages app, reads the code and switches back, the same way you would.
Wrapping up
OTP isn't broken, it's working as designed. The fix is to put the code somewhere your automation can legitimately reach it. If that somewhere is a real phone with a real number, you can get one at cloud.mobilerun.ai.
Also Read:
more from
the blog
How to automate app testing across multiple devices
Set up multiple Mobilerun cloud phones and run the same plain-language test across Android and iOS, including onboarding, localization, and a UI/UX walkthrough
How to watch an app and get automated alerts using Mobilerun
Set up a Mobilerun cloud phone and a daily 10 AM routine that opens an app, checks prices and offers, and alerts you only when something changed.
How to get app data from different countries using Mobilerun
A VPN rarely changes the Play Store catalog or in-app prices. Play country follows your Google account, and apps also check GPS, locale, and carrier. Here's how to extract regional app data from a cloud phone.