Whatsapp Api - How to automatically send pre-filled message which is in the url

Whatsapp Api - How to automatically send pre-filled message which is in the url

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Whatsapp Api - How to automatically send pre-filled message which is in the url

You can generate a link that opens WhatsApp and populates the input field with a specific message using the https://wa.me/ protocol. This method relies on standard URL parameters rather than complex API keys or server-side logic. The format follows this pattern:

https://wa.me/{phone_number}?text={url_encoded_text}

The phone number must be provided in international format without the leading plus sign, though including + is often accepted depending on the client implementation. For example, if you are targeting a US number like 1-555-123-4567, the link would look like this:

https://wa.me/15551234567?text=I%20am%20interested%20in%20your%20car%20for%20sale

Notice how spaces and special characters in the message are automatically converted to percent-encoded strings. The %20 represents a space, while ampersands or other symbols require their own specific hex codes. This ensures that when the user clicks the link on Android or iOS, the WhatsApp app decodes the string and places it exactly where the cursor belongs in the chat interface.

There is also an alternative approach using the https://api.whatsapp.com/send endpoint. This is often preferred when you need to open a direct conversation with a specific contact ID rather than just opening the app with a number. The syntax shifts slightly:

<a href="https://api.whatsapp.com/send?phone=0123456789&amp;text=I'm%20interested%20in%20your%20services" target="_blank">Click to WhatsApp Chat</a>

In this example, the amp; is necessary because you are embedding this link inside an HTML attribute. If you paste a raw ampersand (&) into your code without escaping it, the browser will interpret it as the start of a new parameter or break the attribute string.

The Limitation: Why It Doesn't Auto-Send

The core constraint here is security and user consent. WhatsApp’s architecture deliberately separates opening a chat from sending a message. Even if you encode a text string in the URL parameters, clicking the link only populates the input field; it does not trigger an HTTP POST request to deliver the payload.

This behavior exists because auto-sending messages without explicit user interaction would violate privacy guidelines and spam policies enforced by Meta. The platform requires a deliberate "Send" action—either tapping the send button or hitting enter in the input box—to confirm that the recipient is receiving a message they expect. Consequently, there is no standard GET parameter or URL flag that bypasses this requirement to automatically dispatch the text upon link activation.

Implementation Strategies for Developers

If your goal is to streamline the user experience where a visitor clicks an icon and their query goes directly to support, you must guide them through the final step. You can achieve this by pre-filling the message and then programmatically focusing on the input field once the WhatsApp app loads.

Since browsers cannot execute JavaScript inside https://wa.me or api.whatsapp.com links due to Same-Origin Policy restrictions, you cannot rely solely on client-side scripts in your own website to trigger the send action after the external link opens. The handoff occurs entirely on the user's device.

To make this seamless, consider these implementation details:

  1. Pre-fill and Focus: Use a JavaScript snippet on your landing page to detect when the WhatsApp window has opened (if using an iframe) or simply rely on the native app behavior where the input field is often focused automatically by the OS once the link is accepted.
  2. User Guidance: Clearly label the button as "Chat with Us" rather than "Send Message." This manages expectations that the user must hit send.
  3. Fallback Mechanisms: If your business logic requires an immediate delivery, consider integrating a webhook-based solution via the WhatsApp Business API, which allows programmatic message sending after the conversation is initiated or even before, provided you have the necessary permissions and tokens.

Conclusion on URL Pre-filling

While you cannot force the message to transmit automatically via a simple URL parameter, the pre-filled link method significantly reduces friction. It eliminates the need for the user to type common phrases like "Hello" or "Hi," effectively pre-composing the intent of the conversation. For many business use cases, this reduction in typing effort is sufficient to drive high conversion rates without needing to bypass WhatsApp's security model regarding message dispatch.

Our network