diff --git a/README.md b/README.md
index 737be51..6bb11fe 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,14 @@ Admin Node generate QR Code just below the node for easy connection with whatsap
3. **Chats Out** : As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node.
- *Don't forget to mention international dialing code befor your number. Number must be in format like `+11 99999 99999` without any space.*
+
Don't forget to mention international dialing code befor your number.
+ Number must be in format like +11 99999 99999 without any space.
+ OR
+ Leave the Number blank and provide the number along with paylod
+ at `msg.toNumber` with international code.
+ To send message on multiple contacts an Arrar of number can be passed
+ on `msg.toNumber` like `msg.toNumber = [+1199999999, +12990000099, +1311111111].
+
4. **Group Message** : Whatsapp Group Node to send message in a Group.
@@ -63,7 +70,7 @@ Admin Node generate QR Code just below the node for easy connection with whatsap
5. **Reply Node** : In Beta mode.
-Node will reply on each message starting with string mentioned in instruction or defaults `!red`.
+Node will reply(the `payload`) on each message starting with string mentioned in instruction coloum or defaults `!red`.
## Issues & Updates
@@ -73,11 +80,14 @@ Issues and Suggestions are welcome [here.](https://github.com/raweee/node-red-co
* `Ver-0.1.21` : Group Message Node added.
* `Ver-0.1.23` : Nodes are formatted correctly and names are updated.
* `Ver-0.1.28` : Now QR Codes are directlly avilable in run time on Whatsapp-Admin-Node.
+* `Ver-0.1.30` : Message can be send to an Array of contacts provided at `msg.toNumber`.
* Working on Reply Node.
## Future Nodes
Currently working on more Whatsapp Node and will be avilable soon -
1. Chat Reply node. (working)
+2. Whatsapp button message.
+3. Whatsapp List message.
2. Instruction (smart) Reply Node.
Complete detail for Nodes will also be updated as soon as possible.
diff --git a/chats-out.html b/chats-out.html
index 66fdfc4..d978a0a 100644
--- a/chats-out.html
+++ b/chats-out.html
@@ -33,6 +33,11 @@
diff --git a/chats-out.js b/chats-out.js
index c31323d..fc5d51b 100644
--- a/chats-out.js
+++ b/chats-out.js
@@ -9,30 +9,42 @@ module.exports = function(RED) {
let SetStatus = function(WAStatus, color){
node.status({fill:color,shape:"dot",text:WAStatus});
};
+ const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
- node.on('input', (message)=> {
- if (node.number){
- node.number = node.number.replace(/\D/g, '');
- node.number = `${node.number}@c.us`;
+ function whatsappMessage(numb , inputMessage){
+ if (node.waClient){
try {
- node.waClient.sendMessage(node.number, message.payload);
+ numb = typeof numb ==='number' ? numb : numb.replace(/\D/g, '');
+ numb = `${numb}@c.us`;
+ node.waClient.sendMessage(numb, inputMessage);
SetStatus("Message Send.", "green");
setTimeout(()=>{
SetStatus('Connected','green');
- }, 3000)
+ }, 2000)
}
catch(e) {
node.log(`Error Sending Msg: ${e}`);
- };
- }
- else {
+ }
+ } else { node.log(`Error Sending Msg: ${e}`)}
+ };
+
+ node.on('input', (message)=> {
+ if (node.number){
+ whatsappMessage(node.number, message.payload);
+
+ } else if (message.toNumber){
+ var numbers = typeof message.toNumber === 'number' ? Array.of(message.toNumber) : message.toNumber;
+ for (number of numbers) {
+ setTimeout(()=> {
+ whatsappMessage(number, message.payload)}
+ , 3000);
+ }
+ } else {
SetStatus("No number","red");
setTimeout(()=>{
SetStatus('Connected','green');
}, 5000)
}
-
-
});
//whatsapp Status Parameters----
diff --git a/package-lock.json b/package-lock.json
index 2616981..f5a0a35 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,17 +1,16 @@
{
"name": "node-red-contrib-whatsapp-link",
- "version": "0.1.25",
+ "version": "0.1.30",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "node-red-contrib-whatsapp-link",
- "version": "0.1.25",
+ "version": "0.1.30",
"license": "ISC",
"dependencies": {
- "puppeteer": "latest",
"qrcode": "^1.5.1",
- "whatsapp-web.js": "^1.18.4"
+ "whatsapp-web.js": "latest"
},
"engines": {
"node": ">=8.0.0"
@@ -23,9 +22,9 @@
"integrity": "sha512-wtnBAETBVYZ9GvcbgdswRVSLkFkYAGv1KzwBBTeRXvGT9sb9cPllOgFFWXCn9PyARQ0H+Ijz6mmoRrGateUDxQ=="
},
"node_modules/@types/node": {
- "version": "18.11.9",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
- "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
+ "version": "18.11.18",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
+ "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==",
"optional": true
},
"node_modules/@types/yauzl": {
@@ -374,6 +373,25 @@
"node-fetch": "2.6.7"
}
},
+ "node_modules/cross-fetch/node_modules/node-fetch": {
+ "version": "2.6.7",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
+ "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
+ "dependencies": {
+ "whatwg-url": "^5.0.0"
+ },
+ "engines": {
+ "node": "4.x || >=6.0.0"
+ },
+ "peerDependencies": {
+ "encoding": "^0.1.0"
+ },
+ "peerDependenciesMeta": {
+ "encoding": {
+ "optional": true
+ }
+ }
+ },
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -838,9 +856,9 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/node-fetch": {
- "version": "2.6.7",
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
- "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
+ "version": "2.6.8",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.8.tgz",
+ "integrity": "sha512-RZ6dBYuj8dRSfxpUSu+NsdF1dpPpluJxwOp+6IoDp/sH2QNDSvurYsAa+F1WxY2RjA1iP93xhcsUoYbF2XBqVg==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
@@ -983,6 +1001,7 @@
"version": "13.7.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-13.7.0.tgz",
"integrity": "sha512-U1uufzBjz3+PkpCxFrWzh4OrMIdIb2ztzCu0YEPfRHjHswcSwHZswnK+WdsOQJsRV8WeTg3jLhJR4D867+fjsA==",
+ "deprecated": "< 18.1.0 is no longer supported",
"hasInstallScript": true,
"dependencies": {
"cross-fetch": "3.1.5",
@@ -1051,9 +1070,9 @@
}
},
"node_modules/readdir-glob/node_modules/minimatch": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
- "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
+ "version": "5.1.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.4.tgz",
+ "integrity": "sha512-U0iNYXt9wALljzfnGkhFSy5sAC6/SCR3JrHrlsdJz4kF8MvhTRQNiC59iUi1iqsitV7abrNAJWElVL9pdnoUgw==",
"optional": true,
"dependencies": {
"brace-expansion": "^2.0.1"
@@ -1273,9 +1292,9 @@
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/whatsapp-web.js": {
- "version": "1.18.4",
- "resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.18.4.tgz",
- "integrity": "sha512-Dqu6Q37tDDAcVJ44aMdRE76sI/9rBCUG+NTz1Kxh2w4obX2WtpoRetilxqgx1r4+pFUl58Lf21wGOEwPZ1pT/A==",
+ "version": "1.19.2",
+ "resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.19.2.tgz",
+ "integrity": "sha512-ibEKy0KJsmH1rH9DKXfWk9vCnP/Dw/nZF9Ax3M7LCYtumSC+fiXMRF3BMVu7E75NRdv1pzjw4v05/Oq9aYY6aA==",
"dependencies": {
"@pedroslopez/moduleraid": "^5.0.2",
"fluent-ffmpeg": "^2.1.2",
@@ -1426,9 +1445,9 @@
"integrity": "sha512-wtnBAETBVYZ9GvcbgdswRVSLkFkYAGv1KzwBBTeRXvGT9sb9cPllOgFFWXCn9PyARQ0H+Ijz6mmoRrGateUDxQ=="
},
"@types/node": {
- "version": "18.11.9",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
- "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
+ "version": "18.11.18",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
+ "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==",
"optional": true
},
"@types/yauzl": {
@@ -1695,6 +1714,16 @@
"integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
"requires": {
"node-fetch": "2.6.7"
+ },
+ "dependencies": {
+ "node-fetch": {
+ "version": "2.6.7",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
+ "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
+ "requires": {
+ "whatwg-url": "^5.0.0"
+ }
+ }
}
},
"debug": {
@@ -2075,9 +2104,9 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node-fetch": {
- "version": "2.6.7",
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
- "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
+ "version": "2.6.8",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.8.tgz",
+ "integrity": "sha512-RZ6dBYuj8dRSfxpUSu+NsdF1dpPpluJxwOp+6IoDp/sH2QNDSvurYsAa+F1WxY2RjA1iP93xhcsUoYbF2XBqVg==",
"requires": {
"whatwg-url": "^5.0.0"
}
@@ -2234,9 +2263,9 @@
}
},
"minimatch": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
- "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
+ "version": "5.1.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.4.tgz",
+ "integrity": "sha512-U0iNYXt9wALljzfnGkhFSy5sAC6/SCR3JrHrlsdJz4kF8MvhTRQNiC59iUi1iqsitV7abrNAJWElVL9pdnoUgw==",
"optional": true,
"requires": {
"brace-expansion": "^2.0.1"
@@ -2419,9 +2448,9 @@
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"whatsapp-web.js": {
- "version": "1.18.4",
- "resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.18.4.tgz",
- "integrity": "sha512-Dqu6Q37tDDAcVJ44aMdRE76sI/9rBCUG+NTz1Kxh2w4obX2WtpoRetilxqgx1r4+pFUl58Lf21wGOEwPZ1pT/A==",
+ "version": "1.19.2",
+ "resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.19.2.tgz",
+ "integrity": "sha512-ibEKy0KJsmH1rH9DKXfWk9vCnP/Dw/nZF9Ax3M7LCYtumSC+fiXMRF3BMVu7E75NRdv1pzjw4v05/Oq9aYY6aA==",
"requires": {
"@pedroslopez/moduleraid": "^5.0.2",
"archiver": "^5.3.1",
diff --git a/package.json b/package.json
index 4024b03..711e894 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "node-red-contrib-whatsapp-link",
- "version": "0.1.29",
- "description": "Node to send and receive whatsapp chats and group messages. | No third party APIs",
+ "version": "0.1.30",
+ "description": "Node to send and receive whatsapp messages in groups and chats. | No third party APIs",
"repository": {
"type": "git",
"url": "git+https://github.com/raweee/node-red-contrib-whatsapp-link.git"
@@ -31,7 +31,7 @@
},
"dependencies": {
"qrcode": "^1.5.1",
- "whatsapp-web.js": "^1.18.4"
+ "whatsapp-web.js": "latest"
},
"engines": {
"node": ">=8.0.0"