DEV Community

Azam Sajid
Azam Sajid

Posted on • Originally published at waaibot.com

How to Send Automated WhatsApp Messages from Oracle APEX (The Modern Way)

The Challenge: Beyond Standard Emails

In modern ERP and CRM systems built on Oracle APEX, email notifications are no longer enough. Customers want real-time updates—order confirmations, shipping alerts, and OTPs—delivered directly to WhatsApp.

While you can use UTL_HTTP, the modern standard for APEX developers is APEX_WEB_SERVICE. It’s cleaner, handles CLOBs better, and simplifies the REST call.


Oracle APEX WhatsApp Integration Architecture using PL/SQL

Method 1: Using APEX_WEB_SERVICE.MAKE_REST_REQUEST (Recommended)

This is the most efficient way. It integrates directly with the APEX engine and makes handling JSON payloads a breeze.

DECLARE
  l_response CLOB;
  l_url      VARCHAR2(400) := 'https://api.waaibot.com/api/v1/send';
  l_api_key  VARCHAR2(100) := 'YOUR_API_KEY';
  l_body     CLOB;
BEGIN
  -- Constructing the JSON Payload
  l_body := '{"number": "923001234567", "message": "Your Order #1029 is ready for dispatch!"}';

  -- Setting headers and making the request
  apex_web_service.g_request_headers(1).name  := 'Content-Type';
  apex_web_service.g_request_headers(1).value := 'application/json';
  apex_web_service.g_request_headers(2).name  := 'Authorization';
  apex_web_service.g_request_headers(2).value := 'Bearer ' || l_api_key;

  l_response := apex_web_service.make_rest_request(
    p_url         => l_url,
    p_http_method => 'POST',
    p_body        => l_body
  );

  -- Output response for debugging
  DBMS_OUTPUT.put_line('Response: ' || l_response);
END;

Enter fullscreen mode Exit fullscreen mode

Method 2: The Legacy UTL_HTTP Approach

If you are working in a pure PL/SQL environment outside of an APEX session (like a background DBMS_JOB), you’ll need UTL_HTTP. This requires your Oracle Wallet to be configured for SSL.

Note: Waaibot uses a hybrid socket connection, which means you don't need to worry about complex Meta Business verification just to send a notification to your own customers.


Why this Architecture Wins for Oracle Developers:

  • Zero Infrastructure: No need to set up a Node.js middleware. Your database talks directly to the WhatsApp gateway.
  • Cost Efficiency: Unlike the official Cloud API that charges per message, using a socket-based API at waaibot.com allows for high-volume notifications without the "Meta tax."
  • Security: By using APEX_WEB_SERVICE, you can store your API keys in APEX Web Credentials for maximum security.

Pro-Tip: Handling the Response

Always wrap your call in a JSON_TABLE query to log the message_id. This allows you to track delivery statuses directly inside your APEX dashboard.

Want to try this in your dev environment? Grab a free API key at waaibot.com and start sending messages in under 5 minutes.

Top comments (0)