A Node.js module for sending WhatsApp messages using a third-party API.
Install the module using npm:
npm install onxy-messaging
Usage
const OnxyMessaging = require('onxy-messaging');
const yourId = 'your_id';
const apiKey = 'your_api_key';
const onxy = new OnxyMessaging(yourId, apiKey);
// Example: Sending a simple text message
onxy.sendSimpleTextMessage('recipient_number', 'Hello, this is a test message')
.then(response => console.log(response))
.catch(error => console.error(error));
// Other methods:
// - onxy.sendMediaFromURL('recipient_number', 'media_url', 'Optional caption')
// - onxy.sendTextInGroup('group_name', 'message')
// - onxy.sendMediaFromURLInGroup('group_name', 'media_url', 'Optional caption')
API Methods
sendSimpleTextMessage(number, message)
Send a simple text message to the specified number.
number: Recipient's phone number.
message: Text message to be sent.
sendMediaFromURL(number, url, caption)
Send images/PDF/documents, etc., from a URL to the specified number.
number: Recipient's phone number.
url: URL of the media file.
caption (Optional): Caption for the media file.
sendTextInGroup(groupName, message)
Send a text message to a WhatsApp group.
groupName: Name of the WhatsApp group.
message: Text message to be sent.
sendMediaFromURLInGroup(groupName, url, caption)
Send images/PDF/documents, etc., from a URL to a WhatsApp group.
groupName: Name of the WhatsApp group.
url: URL of the media file.
caption (Optional): Caption for the media file.
License
This project is licensed under the MIT License - see the LICENSE file for details.