wa.me Links Explained: Formats, Encoding and Gotchas for Pre-Filled WhatsApp Messages
Click-to-chat links ( https://wa.me/ ?text=) look trivial, but they break in surprisingly common ways. Here’s what to get right. The number format Full international format: country code + number No +, spaces, dashes or brackets Drop the national leading zero: UK 07700 900123 becomes 447700900123 A quick JavaScript helper: js function waLink(number, message = '') { const digits =…
Click-to-chat links using wa.me format are simple yet prone to common issues. To create a working link, use full international format for the phone number, dropping any non-digits, national leading zero, and special characters. Encode the message text using UTF-8 encoding, replacing spaces with %20, new lines with %0A, and other special characters with their respective encoded values.
JavaScript offers a helper function to generate these links, while PHP users can use rawurlencode() instead of urlencode(), which converts spaces into +. Be aware that links open WhatsApp Web on desktop, and users can edit the pre-filled text. Automated messages require the WhatsApp Business API, and the number must be registered on WhatsApp to avoid errors.
Brief written by urgent.news from Dev.to's own syndicated text. Machine-written — may contain errors; check the original before relying on it.