Answer

How to Force SMS Verification Code in Telegram Automation Safely

Last updated: 2026-07-19

Force SMS Code in Telethon with `force_sms=True`

To force Telegram to send your login verification code via SMS instead of an in-app notification, pass `force_sms=True` to `client.send_code_request(phone)` in Telethon. This tells Telegram's servers to deliver the code to your phone number as a text message, bypassing the default in-app delivery that requires the Telegram app to be open on a logged-in device.

This matters most when you're running automation on a server or VPS where the Telegram desktop or mobile app isn't installed — in that scenario, an in-app code notification is useless because there's no app to receive it.

Why Telegram Defaults to In-App Codes

When you call `send_code_request`, Telegram decides how to deliver the code based on your account's active sessions. If you already have the Telegram app installed and logged in on a phone, Telegram sends the code as an in-app message — it's faster, costs Telegram nothing, and most users prefer it. The problem is that for automation workflows, you often don't have the app running on the same machine where your script executes.

The response object from `send_code_request` includes a `type` attribute that tells you what happened:

  • `SendCodeTypeApp` — code was sent via the Telegram app
  • `SendCodeTypeSms` — code was sent via SMS
  • `SendCodeTypeCall` — code will be delivered via a phone call
  • `SendCodeTypeFlashCall` — code delivered via a missed call pattern

If you get `SendCodeTypeApp` and need SMS, that's when `force_sms=True` comes in.

Step-by-Step: Force SMS in Telethon

Here's the minimal working approach:

```python from telethon import TelegramClient

api_id = 123456 # your API ID from my.telegram.org api_hash = 'your_hash' # your API hash phone = '+1234567890' # phone number in international format

client = TelegramClient('session_name', api_id, api_hash) client.connect()

# First attempt — may send via app result = client.send_code_request(phone)

# If the code came via app and you need SMS, force it: result = client.send_code_request(phone, force_sms=True)

# Now sign in with the SMS code you received client.sign_in(phone, code='12345') # replace with actual SMS code ```

A few things to keep in mind:

  1. Rate limits apply. Telegram throttles code requests. If you call `send_code_request` too many times in a short window, you'll hit a `FloodWaitError` and be locked out for a period (often 12–24 hours). Don't loop aggressively.
  1. `force_sms` works on the second call. In practice, the first `send_code_request` often sends via app. Calling it again with `force_sms=True` triggers the SMS path. You don't need to wait for the first code to expire.
  1. Session files persist. Once you've successfully signed in, Telethon saves a `.session` file. On subsequent runs, you won't need to re-authenticate at all — the session is reused. The SMS flow is a one-time setup per session.
  1. 2FA passwords are separate. If the account has two-step verification enabled, `sign_in` will raise `SessionPasswordNeededError`. You then call `client.sign_in(password='your_2fa_password')` to complete login.

Handling Common Errors

FloodWaitError: You've requested too many codes. The exception tells you how many seconds to wait. Respect it — retrying immediately extends the wait.

PhoneNumberBannedError: The number is banned from Telegram. No workaround; use a different number.

PhoneNumberUnoccupiedError: The number isn't registered on Telegram. You'd need to sign up first using `client.sign_up()`.

When Manual Code Entry Becomes a Bottleneck

The SMS verification flow is fine for a single account or a small project. But if you're managing multiple Telegram channels, handling audience engagement, and trying to grow — manually entering SMS codes for each session becomes tedious fast. This is where the gap between a library like Telethon and a full automation platform shows up.

Telethon is a powerful Python framework for building Telegram bots and scripts, and it's excellent for developers who want full control. You can read more about how it compares to AI-driven agent approaches in our breakdown of open-source Telegram bot frameworks vs AI agents. But Telethon doesn't manage channel growth, monetization, or audience engagement on its own — you'd build all of that yourself.

Bot App takes a different angle on this problem. Instead of requiring you to write Python scripts, handle session files, and manage authentication flows manually, it provides AI-powered automation that runs 24/7 to engage users, manage interactions, and handle channel growth. Within the WONIX Web3 ecosystem, it also handles the monetization layer — earning passive income and lifetime rewards while the AI manages operational growth. The security side is handled through encrypted, secure AI technology backed by the WONIX ecosystem, so you're not managing API credentials and session files yourself.

Which Approach Fits Your Situation

Use Telethon with `force_sms=True` if:

  • You're a developer comfortable with Python
  • You need fine-grained control over Telegram API calls
  • You're building a custom bot or integration
  • You're running scripts on a headless server

Consider Bot App if:

  • You want to grow and monetize Telegram channels without writing code
  • You need 24/7 automated engagement without manual oversight
  • You're interested in Web3/crypto reward integration
  • You'd rather not manage session files, API credentials, and rate-limit handling yourself

Neither is universally better. If you're a solo developer building a niche tool, Telethon's flexibility wins. If your goal is channel growth and passive income without the engineering overhead, an AI-driven agent like Bot App is the more practical path.

Quick Reference

ScenarioRecommended Approach
Single account, headless serverTelethon + `force_sms=True`
Multiple channels, growth-focusedBot App or similar AI automation
Custom bot with specific API needsTelethon (full control)
No-code, monetization-focusedBot App within WONIX ecosystem

The key takeaway: `force_sms=True` is a one-line parameter that solves a real pain point in Telethon authentication. It's not a hack — it's a supported API feature. Use it when in-app delivery isn't practical, respect Telegram's rate limits, and save your session file so you only go through the flow once.

If you're tired of managing authentication flows and want to focus on growing your Telegram presence instead, download Bot App and let the AI handle the operational side.


Bot App

⬇ Get it on Google Play


*This answer draws on 1 real discussion: Stack Exchange ↗*


Built by Edanic — your AI organic growth team

  1. Rate limits apply. Telegram throttles code requests. If you call sendcoderequest too many times in a short window, you'll hit a FloodWaitError and be locked out for a period (often 12–24 hours). Don't loop aggressively.
  2. forcesms works on the second call. In practice, the first sendcoderequest often sends via app. Calling it again with forcesms=True triggers the SMS path. You don't need to wait for the first code to expire.
  3. Session files persist. Once you've successfully signed in, Telethon saves a .session file. On subsequent runs, you won't need to re-authenticate at all — the session is reused. The SMS flow is a one-time setup per session.
  4. 2FA passwords are separate. If the account has two-step verification enabled, signin will raise SessionPasswordNeededError. You then call client.signin(password='your2fapassword') to complete login.

Real people are asking this

1 real discussion · 1 platform

This page exists because real users asked — it isn't a made-up topic. Every source below links to the original post, so you can verify it yourself.

  • Stack ExchangeHow to force SMS verification code instead of Telegram app notification using Telethon?See original ↗

Sources are public discussions on the platforms shown. We link to the original posts (platform and link only) and never publish real names.

FAQ

Does force_sms=True work on the first send_code_request call?
It can, but in practice Telegram often sends via the app on the first request regardless. The reliable pattern is to call send_code_request once, then call it again with force_sms=True if the first attempt sent the code via the app. You don't need to wait for the first code to expire before requesting again.
What happens if I hit FloodWaitError while trying to force SMS?
Telegram throttles code requests to prevent abuse. FloodWaitError includes a seconds value telling you how long to wait. You must wait that duration before retrying — attempting to bypass it will extend the lockout. For automation, build retry logic that respects the wait time rather than retrying immediately.
Can I avoid the SMS verification entirely after the first login?
Yes. Telethon saves a .session file after successful authentication. On subsequent runs, loading that session file skips the entire code verification flow. The SMS step is a one-time setup per session, not per run.
Is forcing SMS verification safe for my Telegram account?
Using force_sms is a supported Telegram API feature, not a bypass. The risk isn't in the SMS method itself but in how frequently you request codes and whether your automation patterns look like spam. Follow Telegram's terms, avoid aggressive rate patterns, and reuse sessions to minimize authentication requests.

Get Bot App

Download the Bot App app and get started.