Sending codes by SMS and Zalo
People who sign in with a phone number get a one-time code by SMS. The code comes from your own messaging account, not from Thing Edges — so before phone sign-in works, the project needs one configured. Everything below happens in the project, under Apps → Authentication.
📹 Watch the walkthrough — 3½ minutes — narrated in Vietnamese, with the previous dashboard and Lạc Hồng as the example. The steps are the same for any provider.
📹 Adding Zalo — 1½ minutes — the second channel, once SMS is working.
Before you start
Section titled “Before you start”Get these from your SMS provider:
| What | Why it matters |
|---|---|
| Account credentials | The exact fields differ per provider — see the table in step 2 |
| Sender name | What the recipient sees the message from. In Vietnam this is a brandname registered with the provider; on Twilio it is a phone number |
| An approved message template | Vietnamese carriers only deliver text that was registered and approved in advance. The message you save here must match it exactly |
| IP allowlist | Some gateways only accept calls from known addresses. Ours is 42.117.9.161 — send it to your provider if they ask |
You can save a configuration without an approved template, but carriers will drop the messages.
1. Turn on phone sign-in
Section titled “1. Turn on phone sign-in”The Sign-in card decides how people get into your app:
| Setting | What it does |
|---|---|
| Phone sign-in | Lets people sign in with a phone number |
| Sign in without a password | The one-time code replaces the password entirely — nothing to remember, nothing to reset |
| Verify email on sign-up | People who register by email confirm it before they can sign in |
2. Pick a provider
Section titled “2. Pick a provider”The Code delivery card starts at None, labelled Not set up: no account is sending anything yet. Pick your provider and the rest of the form appears.
| Provider | Channels | What you enter |
|---|---|---|
| eSMS.vn | SMS | API key, Secret key |
| Lạc Hồng | SMS and Zalo | Username, Password |
| tinnhanthuonghieu.vn | SMS | User, Password, CP code |
| Twilio | SMS | Account SID, Auth token |
| Other | SMS | Your own endpoint, request body and credentials |
Pick Other only if your provider is not listed: it asks for the send URL and the request body, so you need their API documentation in front of you.
3. Enter the account
Section titled “3. Enter the account”Sender name is the name recipients see. It must be the one registered to this account — gateways reject anything else, and a name that was never registered gets dropped by the carrier even when the gateway accepts it. Vietnamese carriers normally deliver names of 11 characters or fewer; a longer one is saved and accepted here, but may still never arrive. On Twilio, this field is the sending phone number, country code included.
Credentials are encrypted before they are stored and cannot be read back. On a later visit the fields show Saved — leave them blank to keep the current account, and fill them in only to replace it.
4. Write the message
Section titled “4. Write the message”Under Channels, the SMS channel is there by default:
- The text must match the template your carrier approved — punctuation and spacing included.
- Put
{{otp}}where the code goes. - The grey line underneath previews exactly what a person receives.
Adding Zalo
Section titled “Adding Zalo”Zalo (Lạc Hồng only) is a second channel, added with Add Zalo. Ask your provider for the OA id and the approved ZNS template id; without them nothing is delivered.
Its message box is not like the SMS one, and this is where Zalo usually goes wrong:
- Zalo does not send the text you type there. It sends the template your provider had approved.
- That box carries the template’s parameters, as JSON — for example
{"otp":"{{otp}}","time":2}, wheretimeis whatever your template calls its validity field. - Plain text in that box is accepted by the gateway and then never delivered, which looks like success on this screen and like silence on the handset.
The order in the list is the order channels are tried, and the arrows beside each channel change it. Zalo above SMS means Zalo is tried first and SMS catches whoever has no Zalo — that is what Try the next channel when one fails is for.
5. Save, then send a test
Section titled “5. Save, then send a test”Save changes only lights up when something changed, and leaving the tab with unsaved edits asks for confirmation.
After saving you get a Send test message button:
- The number needs its country code —
+84975907414. A local0975…is rejected. - It sends your saved message with a fresh random code, as long as this project’s codes are.
- Your provider charges for it, like any other message.
| Label on the card | Meaning |
|---|---|
| Working | The gateway accepted the message |
| Last test failed | The gateway refused it, with the reason |
Working means accepted, not delivered. The carrier can still drop a message whose sender name or content was never approved. The only proof of delivery is the handset.
Code limits
Section titled “Code limits”Open Advanced: OTP limits in the Sign-in card. An empty field uses the platform default, and each field shows its range and the value in force.
| Limit | Range | Default | What it bounds |
|---|---|---|---|
| Digits in a code | 6–8 | 6 | How long the code is |
| Code stays valid for | 60–600 s | 300 | How long a code lives. Keep it equal to any validity time your message states |
| Wait before another code | 15–300 s | 30 | The gap between two codes to the same number |
| Wrong tries allowed | 1–5 | 5 | Wrong guesses before the code is cancelled |
| Codes per number per hour | 1–10 | 5 | Messages one number can trigger in an hour |
| Codes per number per day | 0–50 | 0 = off | A daily ceiling for one number, counted over a rolling 24 hours |
| Codes for this project per day | 0–100000 | 0 = off | A daily ceiling for the whole project, every number together |
| Requests from one network | 5–300 | 30 | Code requests from one address within the window below |
| Counted over | 10–600 s | 60 | Length of that window |
The two daily ceilings arrive off, because a limit nobody asked for would start turning real users away on the first busy day. Turn them on when cost matters:
- Codes per number per day stops one person requesting codes all day.
- Codes for this project per day is the only limit that is not per number. Every other one counts a single phone number, so a script sending one code each to ten thousand numbers passes them all; this is what bounds what a day can cost. Set it well above a busy day — it is a ceiling against a runaway, not a budget.
When someone hits a limit, the app receives the error together with the seconds left to wait. Count down from that value rather than from a timer in the app: a person who force-quits and reopens otherwise gets a fresh countdown that does not match the server.
Other delivery settings
Section titled “Other delivery settings”Advanced in the Code delivery card holds the rest:
| Setting | Use it for |
|---|---|
| Sending turned on | Pause delivery without deleting the account |
| Try the next channel when one fails | With more than one channel, fall through instead of failing |
| Channel choice in the app | Whether a channel picked by the user is honoured, preferred, or ignored |
| Phone number format | How numbers are written for this gateway (84…, 0…, +84…) |
When a code does not arrive
Section titled “When a code does not arrive”| What you see | Usual cause |
|---|---|
| Last test failed | Wrong credentials, a sender name that does not belong to the account, or no credit left |
| Working, but no message on the handset | The sender name or the message text was never approved by the carrier |
| Zalo reports success but nothing arrives | The Zalo message box holds plain text instead of the template’s JSON parameters |
| Works sometimes, fails sometimes | Gateways refuse a message identical to the one they just sent to the same number — Zalo answers 208. Test sends use a random code, so this shows up mainly with fixed content |
| Worked before, stopped | Credit ran out, or the provider stopped accepting our IP |
Good to know
Section titled “Good to know”- Every test send is a real message and is billed by your provider.
- Each project has its own configuration; turning this on for one project changes nothing for another.
- Every send is recorded — number, time, channels tried, and the gateway’s answer — and kept for 90 days, so an invoice can be checked against it.