Batch SMSCAMPAIGN AUTOMATION

Batch SMS Campaign Automation · Python CLI

Prepare carefully.
Send deliberately.

A consent-first Python workflow to validate recipients, prepare personalized SMS, and deliberately submit reviewed campaigns through an Android gateway.

Real submission requires a separate Android phone running SMS Gateway for Android. This website never sends messages.

Explore the optional Dry Run

An intentional path from draft to submission.

Software checks support your review. They do not establish consent or guarantee delivery.

  1. PrepareOperator reviews the list and template.
  2. ValidateCLI normalizes numbers and checks consent assertions.
  3. ExcludeOpt-outs and conflicting duplicates are blocked.
  4. PreviewCLI reports eligibility and estimated cost.
  5. AuthorizeOperator explicitly confirms the campaign.
  6. ReconcileOperator checks uncertain gateway outcomes.

THE ANDROID CONNECTION

Your computer prepares.
Your phone connects to the carrier.

The Python CLI and Android app are separate software. SMS Gateway for Android is an external project, not an app distributed by this repository.

Real submission architecture · not an active connection
  1. 01Python applicationValidate & authorize
    Your computer or runtime
  2. 02Gateway APIAuthenticated request
    HTTPS required by this CLI
  3. 03Android appSMS Gateway for Android
    Your available device
  4. 04SIM & carrierPermissions & mobile service
    Charges and restrictions apply
  5. 05Authorized recipientMay receive the SMS
    Carrier delivery is separate

API acceptance → queueing → device processing → carrier delivery are separate stages. A successful API response is not a delivery receipt. This CLI does not poll delivery receipts.

What you need for real submission

  • A compatible Android smartphone with the official gateway app and appropriate SMS permissions.
  • A suitable SIM, active mobile service, device availability and connectivity for the selected mode.
  • Provider and carrier authorization, with their charges and restrictions reviewed.
  • A separate computer or controlled runtime for Python. This is not an iOS gateway.
Official Android app installation guide

Set up the external app

  1. Follow the official installation and permissions guidance for your device.
  2. Choose a gateway mode below and configure it in the Android app.
  3. Keep gateway credentials private and verify the endpoint contract before any authorized operation.

Installing this repository does not install the phone app. No APK is hosted here.

Public Cloud Server · provider-routed

The CLI calls the provider’s cloud API, which routes queued messages to the registered Android device. The device needs internet connectivity. Phone numbers and message content pass through third-party infrastructure; assess its privacy terms. This client does not implement the provider’s optional end-to-end encryption.

The default endpoint is https://api.sms-gate.app/3rdparty/v1/messages. The existing client uses Basic authentication; the provider now recommends JWT for new integrations while retaining Basic compatibility.

Official cloud setup
Local Server · controlled network

The Python client communicates with the Android device over your controlled network. The official local example uses HTTP, but this CLI refuses plain HTTP for live endpoints. A trusted HTTPS proxy or equivalent TLS deployment is required; do not disable certificate checks. Configure the full compatible URL using SMS_API_ENDPOINT and verify the deployed route/version.

Local mode supports Basic authentication. Network access, device service availability and secure routing are operator responsibilities.

Official local-server setup

Control at the points that matter.

For privately reviewed, permission-based communications. Purchased, scraped and unverified lists must not be used.

Consent-first preflight
Scope, source and timestamp assertions are required for eligibility. They remain operator claims, not legal proof.
Normalized recipients
Iranian mobile normalization, duplicate suppression and conservative consent conflicts. Opt-outs override eligibility.
Personalized, bounded messages
Plain {name} templates, bounded CSV input and recipient counts. Invalid rows prevent live submission.
Conservative estimates
Unicode segment planning, positive live cost caps and paced sequential requests. Estimates are not billing guarantees.
Private rerun journal
Durable claims before requests; accepted entries are skipped. Unknown results require reconciliation, not blind retries.
Redacted diagnostics
Aggregate JSON output, fixed classifications and no provider bodies in logs. Credentials and lists remain private.

QUICK START · NO SMS

Start with a completely offline Dry Run.

Install Python 3.10–3.14 and Git on your computer. Package access is needed during installation; the default first run does not contact a gateway. No Android phone, credentials or .env file is needed for this example.

Windows · PowerShell

Run from a new terminal. The Python launcher selects your installed supported version.

git clone https://github.com/AlirezaBelal/batch-sms-campaign-automation.git
cd batch-sms-campaign-automation
py -3 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
python main.py

If local policy prevents activation, run .\.venv\Scripts\python.exe -m pip install -r requirements.txt, then .\.venv\Scripts\python.exe main.py.

macOS · Terminal

Use an installed Python 3.10–3.14.

git clone https://github.com/AlirezaBelal/batch-sms-campaign-automation.git
cd batch-sms-campaign-automation
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python main.py
Linux · shell

Use Python 3.10–3.14 with its virtual-environment package installed.

git clone https://github.com/AlirezaBelal/batch-sms-campaign-automation.git
cd batch-sms-campaign-automation
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python main.py

What you should see

Two aggregate JSON events: preflight, then summary. The bundled fictional example reports two simulated recipients and zero accepted or queued submissions.

python main.py performs Dry Run only. It does not send SMS or contact a gateway, even when live environment switches have been configured, unless the explicit CLI live request is also supplied.

event: preflight   mode: dry_run
event: summary     simulated: 2
accepted_or_queued: 0   exit_code: 0

Readable extract — actual output is JSON.
Docker · network-disabled Dry Run

Run in a POSIX shell from the repository root. The existing image runs as a non-root user; the example needs no secrets.

docker build -t batch-sms-campaign-automation .
docker run --rm --network none \
  -e SMS_DRY_RUN=true -e SMS_SEND_ENABLED=false \
  -e SMS_CSV_FILE_PATH=/tmp/contacts.csv \
  -v "$PWD/examples/contacts.example.csv:/tmp/contacts.csv:ro" \
  batch-sms-campaign-automation

Docker build needs package access. Durable private state and separately authorized setup are required for any later live container use.

Authorization is a deliberate operator step.

No schedules, automatic sends or blind retries. Development and website demonstrations never transmit SMS.

Advanced · prepare an explicitly authorized live operation
  1. Install and configure the official Android gateway app and selected mode; verify device, carrier and provider requirements.
  2. Privately review the actual consent evidence, recipients and message purpose. Never use the bundled example for real submission.
  3. Maintain a suppression CSV with the phone header and configure SMS_EXCLUSIONS_FILE. There is no automatic inbound STOP handler.
  4. Optionally copy .env.example to a private .env. Configure SMS_USERNAME, SMS_PASSWORD and a trusted HTTPS endpoint. Keep secrets out of source control.
  5. Set the actual CSV path, reviewed non-demo SMS_CONSENT_SCOPE, conservative recipient/rate bounds and positive SMS_ESTIMATED_UNIT_COST / SMS_MAX_ESTIMATED_COST.
  6. Review third-party processing, carrier terms and applicable requirements. No compliance certification is claimed.
  7. Run python main.py and review its Dry Run preflight first.
  8. Only after separate deliberate authorization, the established controls require SMS_DRY_RUN=false, SMS_SEND_ENABLED=true, valid credentials, and --live with matching --campaign-id and --confirm-campaign values. This is not a copy-and-run sending example.
  9. Reconcile unknown or rejected outcomes with the provider. Preserve the journal and stable ID; never delete state or change IDs to force retransmission.

The opt-out snapshot is checked before each request; a small check-to-send race remains. Interrupt a campaign if a withdrawal becomes known. SMS charges may occur; cost caps bound an estimate, not actual billing.

Read the complete authorization and reconciliation guide

Explore the concepts, without transmission.

Campaign Lab is a secondary educational tool. The browser schema id, first_name, course, consent, opt_out and {{first_name}} / {{course}} tokens differ from Python’s consent metadata and {name} template. The engines and CSV files are not interchangeable.

OPTIONAL · CAMPAIGN LAB

Explore a browser-only Dry Run

Browser-only demonstration — no SMS sending. Use fictional fields only.

Use {{first_name}} and {{course}} for synthetic personalization.

0 / 160
Use a local consent ledger

Optional CSV columns: id, first_name, course, consent, opt_out. No phone-number column is accepted.

Up to 1 MiB and 1,000 rows. Valid flags: true/false, yes/no, or 1/0. The file is read into this tab only.

Ready · no messages have been prepared
Sample contacts—
Queued in simulation—
Excluded—
Duplicates blocked—
Estimate—simulation units only
Dry run decisions for synthetic recipients
Sample recipientConsentPersonalized previewDecision

Clear boundaries. No hidden sending.

Identity-wide exclusions

Any opt-out or missing consent on an ID excludes every row for that ID, regardless of order.

Illustrative estimates

The browser uses one planning unit per eligible ID. It is not Python’s segmentation estimate or a provider quote.

Tab-only processing

No phone column, credentials, gateway access, analytics or persistent campaign state. Imported fictional fields stay in memory.

The real CLI runs in your environment. The public website is static. Neither a preflight nor an API acknowledgement proves lawful consent or carrier delivery.

Install locally. Review the first Dry Run.

Understand the workflow before configuring any external integration.