Sending flood alerts to phones in Nepal with Amazon SNS: what it actually took
How I got a Strands agent to text flood-safety advice to a real phone in Nepal (+977) with Amazon SNS: the four setup steps, the Python that sends it, and what still stands between a test and real households.
Why SMS, and why Nepal
Nepal lost people and bridges to floods twice in late 2026. River forecasts exist, but they reach newsrooms, not a family in Arughat. I built Baadhi Saathi ("Flood Friend"), a Strands agent that reads river and rain forecasts and writes three short lines of advice in Nepali.
The last mile matters most. Many people at risk have basic phones without data, and nobody opens an app or a terminal during a flash flood. So the advice has to arrive as a plain SMS.
On 5 November 2026 it did: three texts with Arughat's advice, including the NEOC emergency number (1149), arrived on my phone in Nepal. Here is what it took.
The four steps between "code works" and "phone buzzes"
My delivery code was written and unit-tested days earlier. The first real text still needed four things on my personal AWS account (us-east-1):
1. Permission for the IAM user the code runs as
My code uses an IAM user that only had Bedrock access, so
sns:Publish was denied. I added a small inline policy that allows SMS sending and nothing else:{ "Version": "2012-10-17", "Statement": [{ "Sid": "BaadhiSaathiSms", "Effect": "Allow", "Action": [ "sns:Publish", "sns:GetSMSAttributes", "sns:SetSMSAttributes", "sns:GetSMSSandboxAccountStatus", "sns:ListSMSSandboxPhoneNumbers" ], "Resource": "*" }]}Least privilege: SNS only, and the IAM policy review screen showed "SNS: Limited: List, Read, Write" and no other service.
2. The SMS sandbox
New accounts start in the SNS SMS sandbox: you can only text numbers you have verified. In the console, under SNS → Text messaging (SMS) → Sandbox destination phone numbers, I added my +977 number. AWS texted a one-time code, I typed it in, and the number showed Verified.
That code arriving was the first real proof that SNS can reach a phone in Nepal.
3. The spend limit
SMS has its own monthly account spend limit under Text messaging preferences. Mine was already $1, which is plenty for testing. Check it before you wonder why messages stop.
4. A test from the console before the code
Publish text message, type Transactional, my verified number, one line of text. It arrived. Testing from the console first separates "AWS setup" problems from "my code" problems.
The code that sends it
The agent's advice is packed into at most three texts, then each one is published as a Transactional SMS:
def send(phone: str, text: str, sns=None) -> str: sns = sns or _sns() r = sns.publish(PhoneNumber=phone, Message=text, MessageAttributes={"AWS.SNS.SMS.SMSType": {"DataType": "String", "StringValue": "Transactional"}}) return r["MessageId"]Transactional (not Promotional) is the type meant for time-critical messages like alerts.
Two lessons came from the model's output rather than from SNS:
- Pack, don't trust. Nova Lite sometimes wrote labels like "SMS 1/3", repeated a line, or returned one 600-character paragraph.
to_sms()strips the labels, drops repeated lines, splits long paragraphs at sentence ends (the Nepali danda । as well as full stops) and packs everything into at most three texts of 300 characters or less. Every text costs money, and a wall of text gets ignored.
- Code owns the headline. The risk level (calm, watch, warning, danger) is computed in Python and stamped as the first line. The model writes the advice after it, so it can never soften a danger warning.
Phone numbers live in a gitignored
subscribers.json , never in the repo.Running it:
python -m saathi.push --no-send # print the SMS each subscriber would getpython -m saathi.push --place arughat # send for realOutput from the real run:
sent 1/3 to +977…: 51588cc7-…sent 2/3 to +977…: c47f955d-…sent 3/3 to +977…: 4e493b59-…What it cost
One Nova Lite call (well under one US cent) and four texts to Nepal (one console test plus three from the code), a few cents in total, well inside the $1 spend limit.
What's still missing (honest limits)
- Still in the sandbox. Only verified numbers receive texts. Reaching real households means requesting to leave the sandbox, and I have not done that yet.
- Sender ID and registration rules for Nepal are not clear to me yet. I posted a wish on the AWS Wishlist asking for a per-country page and a guided "test SMS to my country" flow.
- The 06:00 schedule and the IoT gauge trigger are designed but not yet deployed.
- Safe places in the advice are examples that still need confirming with ward offices.
- This supports DHM and ward alerts. It never replaces them.
Takeaways
- Test the delivery path from the console before blaming your code.
- Give the sending identity only the SNS actions it needs.
- Treat model output as a draft: pack, deduplicate and cap it in code before it costs money.
- For alerts, let code decide the severity and the model write the words.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article