UnOfficial java Wrapper for WhatsApp Cloud API
- JDK 11 or higher.
- Apache Maven 3.3.9 or higher
To get started using this package, you will need some informations which you can get by from Facebook Developer Portal
-
Choose Bussiness as an app type
-
Screen Name (This is the app name that is associated with your App ID. You can change it later.)
-
Fill in the basic information such as password...
-
Add products to your app and choose
WhatsApp
-
Copy your
YOUR_TOKEN
. This token will expire in 23 hours. -
Copy
PHONE_NUMBER_ID
, which will be used as the sender number -
create phonenumber of recipients to whom the messages will be delivered
From this page, To send a test message, copy this command, paste it into Terminal, and click Enter. To create your own message template, click here.
Before starting to use the features of the library, you need to fill in the token
retrieved from the facebook developer portal and the phone number
which will be used as the sender's number.
Watchap watchap = new Watchap(YOUR_TOKEN, PHONE_NUMBER_ID);
- Sending Text messages
- Sending Media Messages (images, audio, videos, stickers and documents)
- Sending location messages
- Sending interactive buttons
- Sending template messages
- Send Text Message
watchap.sendMessage("337677xxxx", "this is a message");
- Send Text Message with Preview URL
watchap.sendMessage("337677xxxx", "this is a message", true);
When sending media(image, video, audio, sticker and document ), you can either specify a link containing the media or specify object id.
- When media is an image, audio, document, or video and you are not using a link.
watchap.sendMessage("337677xxxx", "media-link", false);
- When media is an image, audio, document, or video and you are not using a link.
watchap.sendMessage("337677xxxx", "<image-object-id>", false);
- Send Image Message by URL
watchap.sendMessage("337677xxxx", "https://i.picsum.photos/id/866/200/300.jpg?hmac=rcadCENKh4rD6MAp6V_ma-AyWv641M4iiOpe1RyFHeI", true);
- Send Image Message by ID
watchap.sendMessage("337677xxxx", "<image-object-id>", false);
- Send Audio Message by URL
watchap.sendAudio("337677xxxx", "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-15.mp3", true);
- Send Audio Message by ID
watchap.sendAudio("337677xxxx", "<image-object-id>", false);
- Send Video Message by URL
watchap.sendVideo("337677xxxx", "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", true);
- Send Video Message by ID
watchap.sendVideo("337677xxxx", "<image-object-id>", false);
- Send Document Message by URL
watchap.sendDocument("337677xxxx", "https://assets.website-files.com/603d0d2db8ec32ba7d44fffe/603d0e327eb2748c8ab1053f_loremipsum.pdf", true);
- Send Document Message by id
watchap.sendDocument("337677xxxx", "<image-object-id>", false);
- Send Sticker Message by URL
watchap.sendSticker("337677xxxx", "https://s3.getstickerpack.com/storage/uploads/sticker-pack/meme-pack-1/sticker_1.png?363e7ee56d4d8ad53813dae0907ef4c0", true);
- Send Sticker Message by id
watchap.sendSticker("337677xxxx", "<image-object-id>", false);
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Any issues, please report here