Send WhatsApp messages from Oracle ADF Application

Sharing is Caring

Hello Everyone

In this post, I am sharing a method to send WhatsApp messages from Oracle ADF Application using “WhatsApp Click to Chat” feature as WhatsApp doesn’t provide any official API.

Though it’s the extremely simple way and we need not to write a single line of code, We just need to pass some values in an URL to open WhatsApp Click to Chat console.

Created an ADF Application and a page in view controller with two text fields and a button in it. It looks like this

ADF Page to Send WhatsApp Message

and both fields are bonded to the managed bean variables

<af:inputText label="Mobile No." id="it1" value="#{viewScope.SendWhatsAppBean.mobileNo}"
                                  autoSubmit="true"/>
<af:inputText label="Message" id="it2" rows="2" value="#{viewScope.SendWhatsAppBean.message}"
                                  autoSubmit="true"/>

and managed bean just contain simple POJO variables

package sendwhatsappadf.view.bean;


public class SendWhatsAppBean {
    public SendWhatsAppBean() {
    }

    private String mobileNo;
    private String message;

    public void setMobileNo(String mobileNo) {
        this.mobileNo = mobileNo;
    }

    public String getMobileNo() {
        return mobileNo;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }
}

Next is to know about browser-based WhatsApp click to chat feature, It makes use of an API URL

https://api.whatsapp.com/send?phone=&text=

Now on button click, we can pass phone number and text message in this URL to open click to chat console and in ADF we can do this using destination property of af:button.

<af:button text="Send" id="b1" targetFrame="_blank"
 destination="https://api.whatsapp.com/send?phone=#{viewScope.SendWhatsAppBean.mobileNo}&amp;text=#{viewScope.SendWhatsAppBean.message}"
 partialTriggers="it2 it1"/>

In the above XML source, we can see that both values are passed from managed bean variables.

Now run and check application. Enter mobile no., text message on the page

Mobile No and WhatsApp Message

On click of the Send button, WhatsApp click to chat console is opened in a new browser window.

Send WhatsApp messages from Oracle ADF Application

and this button will open the WhatsApp QR code scanner window, In that window scan QR code with your phone and start sending messages.

WhatsApp login console to send message

Using this method we can pass values from ADF bindings to WhatsApp URL and send messages from ADF application.

Cheers 🙂 Happy Learning

Related Posts

4 thoughts on “Send WhatsApp messages from Oracle ADF Application”

Leave a Reply

Your email address will not be published. Required fields are marked *