Urgent.News

What's breaking now, across hundreds of outlets.

Tech

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 (https://wa.me/?text=) may seem simple, but they can break in unexpected ways. To ensure proper functionality, there are a few key points to keep in mind.

First, use full international format for the phone number, which includes the country code followed by the number without any +, spaces, dashes, or brackets. For example, UK number 07700 900123 should be entered as 447700900123.

A helpful JavaScript function for creating these links is:

```js

function waLink(number, message = '') {

const digits = String(number).replace(/\D/g, '');

const text = message ? '?text=' + encodeURIComponent(message) : '';

return 'https://wa.me/' + digits + text;

}

```

For instance, waLink('+91 98765 43210', 'Hi, I need help with order #1042') generates https://wa.me/919876543210?text=Hi%2C%20I%20need%20help%20with%20order%20%231042.

When encoding the message, it's important to encode the entire message, not just spaces. Characters that can break links when left unencoded include space (%20), new line (%0A), ampersand (%26), hash (%23), question mark (%3F), and plus (+). JS users should use encodeURIComponent(), while PHP developers should employ rawurlencode(), which converts spaces to %20.

A few things to note:

1. On desktop, the link will open WhatsApp Web, not the app itself. The pre-filled text can be edited by the user and will not be sent as is.

2. To send automated messages like order updates or reminders, you'll need to use the WhatsApp Business API.

3. The phone number must be registered on WhatsApp. If not, the user will see an error.

For WordPress site owners looking to add WhatsApp capabilities, there are several methods available, from simple links to full API automation.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Building Voice Notes for Firefox: Web Audio API, No Cloud, No Account

Most note-taking apps for remote workers are overkill: accounts, sync, subscriptions, storage limits. For quick voice memos between meetings, I wanted something that worked without any of that.

  • Built Voice Notes extension simplifies voice memos for users.
  • No account, cloud service, or subscription required.
  • Uses Web Audio API and MediaRecorder for recording.

When a Cyberattack Heats Supermarket Refrigerators: Lessons for Developers and Security Engineers

Most cybersecurity headlines involve compromised accounts, stolen credentials, ransomware or leaked databases. But what happens when an attacker gains control of a system responsible for keeping food…

  • French supermarkets' refrigeration systems hacked, causing food loss and fires
  • TFG London incident disrupted IT systems and online services
  • Securing operational technology requires multi-layered security approach

More from Wednesday, 14 October 2026 →