
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ultramsg-whatsapp-api
Advanced tools
Lightweight library for WhatsApp API to send the whatsappp messages in nodejs provided by ultramsg.com
Lightweight library for WhatsApp API to send the whatsappp messages in nodejs provided by Ultramsg.com
npm i ultramsg-whatsapp-api
const ultramsg = require('ultramsg-whatsapp-api');
const instance_id= "instance1150" // Ultramsg.com instance id
const ultramsg_token= "tof7lsdJasdloaa57e" // Ultramsg.com token
const api = new ultramsg(instance_id,ultramsg_token);
(async function () {
var to = "put_your_mobile_number_here"
var body = "Hello world"
const response = await api.sendChatMessage(to,body);
console.log(response)
})();
NOTE: you need replace instance_id and token with yours in ultramsg.com account if you don't have account create one from here
You can use it to create a professional queue for messages, The Messages with less priority value are sent first.
example of usage :
priority = 0: for High priority like OTP messages.
priority = 5: used with general messages.
priority =10: Non-urgent promotional offers and notifications to your customers.
Default value : 10
var to="put_your_mobile_number_here";
var body="Hello world";
var priority=10;
var referenceId="SDK";
const response = await api.sendChatMessage(to,body,priority,referenceId);
console.log(response)
Supported extensions ( jpg , jpeg , gif , png , svg , webp , bmp ) .
Max file size : 16MB .
Max Base64 length : 2,000,000
false : use a previously uploaded file instead of uploading it with each request
true : uploading it each request
var to="put_your_mobile_number_here";
var caption="image Caption";
var image="https://file-example.s3-accelerate.amazonaws.com/images/test.jpg";
var priority=10;
var referenceId="SDK"
var nocache=false;
const response = await api.sendImageMessage(to,caption,image,priority,referenceId,nocache);
console.log(response)
Supported most extensions like ( zip , xlsx , csv , txt , pptx , docx ....etc ) .
Max file size : 100MB .
Max Base64 length : 2,000,000
var to="put_your_mobile_number_here";
var filename="cv.pdf";
var document="https://file-example.s3-accelerate.amazonaws.com/documents/cv.pdf";
const response = await api.sendDocumentMessage(to,filename,document);
console.log(response)
Supported extensions ( mp3 , aac , ogg ) .
Max file size : 16MB .
Max Base64 length : 2,000,000
var to="put_your_mobile_number_here";
var audio="https://file-example.s3-accelerate.amazonaws.com/audio/2.mp3";
const response = await api.sendAudioMessage(to,audio);
console.log(response)
Max file size : 16MB .
Max Base64 length : 2,000,000
var to="put_your_mobile_number_here";
var audio="https://file-example.s3-accelerate.amazonaws.com/voice/oog_example.ogg";
const response = await api.sendVoiceMessage(to,audio);
console.log(response)
Supported extensions ( mp4 , 3gp , mov ) .
Max file size : 16MB .
Max Base64 length : 2,000,000
var to="put_your_mobile_number_here";
var caption="video Caption";
var video="https://file-example.s3-accelerate.amazonaws.com/video/test.mp4";
const response = await api.sendVideoMessage(to,caption,video);
console.log(response)
var to="put_your_mobile_number_here";
var link="https://ultramsg.com";
const response = await api.sendLinkMessage(to,link);
console.log(response)
Example
or
14000000001@c.us,14000000002@c.us,14000000003@c.us
Max length : 300 char, almost 15 contacts
var to="put_your_mobile_number_here";
var contact="14000000001@c.us";
const response = await api.sendContactMessage(to,contact);
console.log(response)
Supports two lines. To use two lines, use the \n symbol.
Max length : 300 char .
var to="put_your_mobile_number_here";
var address="ABC company \n Sixth floor , office 38";
var lat="25.197197";
var lng="55.2721877";
const response = await api.sendLocationMessage(to,address,lat,lng);
console.log(response)
Max length : 4096 char
var to="put_your_mobile_number_here";
var vcard=`BEGIN:VCARD
VERSION:3.0
N:lastname;firstname
FN:firstname lastname
TEL;TYPE=CELL;waid=14000000001:14000000002
NICKNAME:nickname
BDAY:01.01.1987
X-GENDER:M
NOTE:note
ADR;TYPE=home
ADR;TYPE=work
END:VCARD`;
const response = await api.sendVcardMessage(to,vcard);
console.log(response)
var status="expired";
const response = await api.resendByStatus(status);
console.log(response)
var id="123";
const response = await api.resendById(id);
console.log(response)
get the messages that sent by api
var page=1;
var limit=100;
var status="all";
var sort="asc";
var id="";
var referenceId="";
var from="";
var to="";
var ack="";
const response = await api.getMessages(page,limit,status,sort,id,referenceId,from,to,ack);
console.log(response)
const response = await api.getMessageStatistics();
console.log(response)
const response = await api.getInstanceStatus();
console.log(response)
const response = await api.getInstanceQr();
console.log(response)
const response = await api.getInstanceQrCode();
console.log(response)
const response = await api.getInstanceScreenshot();
console.log(response)
or base64
const response = await api.getInstanceScreenshot("base64");
console.log(response)
Get connected phone informations : number , name , image etc..
const response = await api.getInstanceMe();
console.log(response)
sendDelay : Delay in seconds between sending message, Default 1 second
webhook_url : Http or https URL for receiving notifications .
webhook_message_ack : on/off ack (message delivered and message viewed) notifications in webhooks.
webhook_message_received : on/off notifications in webhooks when message received .
webhook_message_create : on/off notifications in webhooks when message create .
webhook_message_download_media : on/off to get received document / media files.
const response = await api.getInstanceSettings();
console.log(response)
Returns the active session if the device has connected to another instance of Web WhatsApp
const response = await api.sendInstanceTakeover();
console.log(response)
Logout from WhatsApp Web to get new QR code.
const response = await api.sendInstanceLogout();
console.log(response)
Restart your instance.
const response = await api.sendInstanceRestart();
console.log(response)
sendDelay : Delay in seconds between sending message .
webhook_url : Http or https URL for receiving notifications .
webhook_message_received : true/false notifications in webhooks when message received .
webhook_message_create : true/false notifications in webhooks when message create .
webhook_message_ack : true/false ack (message delivered and message viewed) notifications in webhooks.
var sendDelay=1;
var webhook_url="";
var webhook_message_received=false;
var webhook_message_create=false;
var webhook_message_ack=false;
var webhook_message_download_media=false;
const response = await api.sendInstanceSettings(sendDelay,webhook_url,webhook_message_received,webhook_message_create,webhook_message_ack,webhook_message_download_media);
console.log(response)
const response = await api.getChats();
console.log(response)
max value : 1000 .
var chatId="14155552671@c.us";
var limit=100;
const response = await api.getChatsMessages(chatId,limit);
console.log(response)
const response = await api.getContacts();
console.log(response)
var chatId="14155552671@c.us";
const response = await api.getContact(chatId);
console.log(response)
const response = await api.getBlockedContacts();
console.log(response)
var chatId="14155552671@c.us";
const response = await api.blockContact(chatId);
console.log(response)
var chatId="14155552671@c.us";
const response = await api.unblockContact(chatId);
console.log(response)
var chatId="14155552671@c.us";
const response = await api.checkContact(chatId);
console.log(response)
Use Issues to contact me
FAQs
Lightweight library for WhatsApp API to send the whatsappp messages in nodejs provided by ultramsg.com
The npm package ultramsg-whatsapp-api receives a total of 237 weekly downloads. As such, ultramsg-whatsapp-api popularity was classified as not popular.
We found that ultramsg-whatsapp-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.