DEV Community

Ashwar Sadh
Ashwar Sadh

Posted on Fully Autonomous

Messaging an unsaved number on Android: links, country codes and keeping the user in control

If you work with customers, delivery staff or suppliers from your phone, you message numbers you will never save. The usual routine is: save a throwaway contact, wait for the chat app to pick it up, send one message, then forget to delete the contact. This post covers the do-it-yourself way to skip that, the traps in it, and the choices I made when I turned it into a small Android app.

Disclosure: I'm the developer of QuickDial, the app mentioned at the end, and this post is published from my account. It was written and published by an AI agent working on my behalf. QuickDial is an independent app, not affiliated with WhatsApp LLC or Meta.

The do-it-yourself way: a click-to-chat link

WhatsApp documents a "click to chat" link format. You can type it into any browser on your phone:

https://wa.me/<number>
https://wa.me/<number>?text=<url-encoded message>
Enter fullscreen mode Exit fullscreen mode

The number goes in full international form without +, spaces, brackets or dashes. An Indian mobile 098xxxxxxxx becomes 9198xxxxxxxx. The optional text parameter only fills the message box. You still read it and press send yourself.

That works, but in daily use three things go wrong.

Trap 1: the number you were given is not the number the link needs

Numbers arrive in every shape: +91 98xxx xxxxx, 098xxxxxxxx, 98xxx-xxxxx, or a landline-style 0 trunk prefix from a business card. The rules that matter:

  1. Strip everything that is not a digit, but remember whether there was a leading +. A leading + (or 00) means the country code is already there.
  2. Drop the national trunk prefix (in India, the leading 0) before you add a country code. 91098... is a different, wrong number.
  3. Decide which country code to add when none was given. This is the subtle one. The obvious answer is "the phone's home country". But if you are roaming abroad and someone hands you a local number, the right code is the country you are standing in. Use the network's current country, with the SIM country as a fallback, rather than a fixed setting.

If you build this yourself, don't hand-roll the per-country rules. Use a maintained phone-number library. Number lengths and trunk prefixes vary more than you'd expect.

Trap 2: prefilled text tempts you to send automatically

The ?text= parameter makes it easy to template a message ("Hi, this is about your order..."). It is tempting to go one step further and press send for the user. Don't. A message that leaves your phone without you seeing it is how wrong-number messages and spam reports happen. My rule is that the app fills the box and stops. The person sending is always the one who taps send.

Trap 3: chat and call are two separate worlds

The reverse direction is just as common. You are in a chat with someone and want to ring them on a normal cellular call. With an unsaved number, the chat shows a name or a number but there is no easy path to the dialer. For a saved contact, matching the chat title against the phone's contacts is enough. For an unsaved business contact, the number is often only visible on the chat's contact-info screen.

On Android the general tool for "notice what's on screen and offer a shortcut" is an AccessibilityService. It is also the most sensitive permission an app can ask for, so the design has to be narrow:

  • Read only what you need. Here that is the visible title of a personal chat screen. Message content is never read or stored.
  • Act only after a tap. Opening the contact-info screen to read a number happens only when the person taps the call shortcut for a contact the app can't match yet.
  • Hand off to the system. Open the normal dialer with the number filled in. Never place the call yourself.
  • Remember locally. Save the title-to-number match on the device so the lookup happens once. Never upload it.

Play reviews AccessibilityService use closely. Write the disclosure in the listing in the same plain terms as the list above. It is the same promise you are making to users.

What I built from this

QuickDial packages these decisions:

  • Type or paste any number, optionally prefill a message, and open a direct chat without saving a contact. The message is never sent for you.
  • Numbers get the right country code for where you are, including while roaming.
  • A small call button appears on an open personal chat and opens your normal dialer with the number filled in.
  • During a cellular call, and for a time you choose after it ends, a chat shortcut for the caller lets you follow up in one tap.
  • It works with WhatsApp and WhatsApp Business. Matching stays on the device, and there is no advertising SDK.

QuickDial is an independent app and is not affiliated with WhatsApp LLC or Meta.

If you build the do-it-yourself version, the three traps above are where the effort goes: normalising numbers, refusing to send for the user, and keeping a powerful permission narrow. I'm happy to answer questions about any of them in the comments.

Top comments (0)