diff --git a/.github/messageScreenShot.jpeg b/.github/messageScreenShot.jpeg
new file mode 100644
index 0000000..832a6cc
Binary files /dev/null and b/.github/messageScreenShot.jpeg differ
diff --git a/README.md b/README.md
index 61361cb..62c956e 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,54 @@ Admin Node generate QR Code just below the node for easy connection with whatsap
| `msg.chatID` | Chat ID of Group chat / Personal chat |
| `msg.message` | Complete message object.
*Some extra details for advance users* |
+ Other Events options --
+
+ | waWebClient | Description |
+ |-------------|-------------|
+ | `message`
+ | `message_create`
+ | `auth_failure`
+ | `authenticated`
+ | `change_battery`
+ | `change_state`
+ | `disconnected`
+ | `group_join`
+ | `group_leave`
+ | `group_update`
+ | `incoming_call`
+ | `media_uploaded`
+ | `message_ack`
+ | `message_reaction`
+ | `message_revoke_everyone`
+ | `message_revoke_me`
+ | `qr`
+ | `ready`
+
+ | waSocketClient | Description |
+ |-------------|----------------|
+ | `messages.upsert`
+ | `connection.update`
+ | `creds.update`
+ | `messaging-history.set`
+ | `chats.upsert`
+ | `chats.update`
+ | `chats.delete`
+ | `presence.update`
+ | `contacts.upsert`
+ | `contacts.update`
+ | `messages.delete`
+ | `messages.update`
+ | `messages.media-update`
+ | `messages.reaction`
+ | `message-receipt.update`
+ | `groups.upsert`
+ | `groups.update`
+ | `group-participants.update`
+ | `blocklist.set`
+ | `blocklist.update`
+ | `call`
+
+
3. **Chats Out** : As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node.
@@ -138,7 +186,7 @@ msg.payload = {
```
Yes its lot require for buttons, A node will come soon to minimize these effors.
-You may direct import these test button with bellow code.
+You may direct import these test button with bellow code.
```json
[
@@ -263,6 +311,9 @@ You may direct import these test button with bellow code.
}
]
```
+### Screen Shots of Buttons and Image Messages.
+
+
5. **Reply Node** : In Beta mode.
@@ -280,6 +331,7 @@ Issues and Suggestions are welcome [here.](https://github.com/raweee/node-red-co
* `Ver-0.1.30` : Message can be send to an Array of contacts provided at `msg.toNumber`.
* `Ver-0.1.32` : Socket based `Whatsapp Lite` config node added in beta mode. Image message sending support added in chats-out node.
* `Ver-0.1.33` : Button and list support added, Minnor bugs fixed.
+* `Ver-0.1.34` : Multiple Events reading options are added in Chats-In Node.
## Future Nodes
Currently working on more Whatsapp Node and will be avilable soon -
diff --git a/admin.js b/admin.js
index 5fb8d20..4155e29 100644
--- a/admin.js
+++ b/admin.js
@@ -6,7 +6,6 @@ module.exports = function(RED) {
var node = this;
var whatsappLinkNode = RED.nodes.getNode(config.whatsappLink);
node.client = whatsappLinkNode.client;
- // RED.comms.publish("whatsappLinkNodeID", node.id)
function SetStatus(WAStatus, color){
node.status({fill:color,shape:"dot",text:WAStatus});
diff --git a/chats-in.html b/chats-in.html
index aaf8936..dab6f29 100644
--- a/chats-in.html
+++ b/chats-in.html
@@ -1,17 +1,89 @@
@@ -41,4 +126,51 @@ Node to recive all messages send to connected number.
| `msg.chatID` | Chat ID of Group chat / Personal chat |
| `msg.message` | Complete message object.
*Some extra details for advance users* |
+ Other Events options --
+
+ | waWebClient | Description |
+ |-------------|-------------|
+ | `message`
+ | `message_create`
+ | `auth_failure`
+ | `authenticated`
+ | `change_battery`
+ | `change_state`
+ | `disconnected`
+ | `group_join`
+ | `group_leave`
+ | `group_update`
+ | `incoming_call`
+ | `media_uploaded`
+ | `message_ack`
+ | `message_reaction`
+ | `message_revoke_everyone`
+ | `message_revoke_me`
+ | `qr`
+ | `ready`
+
+ | waSocketClient | Description |
+ |-------------|----------------|
+ | `messages.upsert`
+ | `connection.update`
+ | `creds.update`
+ | `messaging-history.set`
+ | `chats.upsert`
+ | `chats.update`
+ | `chats.delete`
+ | `presence.update`
+ | `contacts.upsert`
+ | `contacts.update`
+ | `messages.delete`
+ | `messages.update`
+ | `messages.media-update`
+ | `messages.reaction`
+ | `message-receipt.update`
+ | `groups.upsert`
+ | `groups.update`
+ | `group-participants.update`
+ | `blocklist.set`
+ | `blocklist.update`
+ | `call`
+
diff --git a/chats-in.js b/chats-in.js
index 75067d8..24b0dd4 100644
--- a/chats-in.js
+++ b/chats-in.js
@@ -4,21 +4,33 @@ module.exports = function(RED) {
var node = this;
var whatsappLinkNode = RED.nodes.getNode(config.whatsappLink);
node.waClient = whatsappLinkNode.client;
-
+ var whatsappLiteEvents = config.whatsappLiteevent;
+ var whatsappWebEvents = config.whatsappWebevent;
+
function SetStatus(WAStatus, color){
node.status({fill:color,shape:"dot",text:WAStatus});
};
- if(node.waClient.clientType === "waWebClient"){
- node.waClient.on('message', async message => {
- let msg = {};
- msg.payload = message.body;
- msg.from = message.author || message.from ;
- msg.chatID = message.from.replace(/\D/g, '');
- msg.from = msg.from.replace(/\D/g, '');
- msg.message = message ;
- node.send(msg);
- });
+ if(node.waClient.clientType === "waWebClient"){
+ whatsappWebEvents = whatsappWebEvents?.split(",") || whatsappWebEvents ;
+ whatsappWebEvents?.forEach((waEvent)=>{
+ if (waEvent ==='message'){
+ node.waClient.on(waEvent, async message => {
+ let msg = {};
+ msg.payload = message.body|| null;
+ msg.from = message.author || message.from ;
+ msg.chatID = message.from.replace(/\D/g, '');
+ msg.from = msg.from.replace(/\D/g, '');
+ msg.message = message ;
+ node.send(msg);
+ });
+ } else {
+ node.waClient.on(waEvent, async message => {
+ node.send(message);
+ });
+ };
+ })
+
//whatsapp Status Parameters----
node.waClient.on('qr', (qr) => {
@@ -46,18 +58,28 @@ module.exports = function(RED) {
var client = null
async function clientFromWhatsappLite(){
client = await node.waClient;
-
- client.ev.on('messages.upsert', msgs =>{
- msgs.messages.forEach(async msg =>{
- msg.payload = msg.message?.conversation;
- msg.from = msg.key.participant || msg.key.remoteJid;
- msg.from = msg.from.replace(/\D/g, '') || msg.from;
- msg.chatID = msg.key.remoteJid.replace(/\D/g, '') || msg.key.remoteJid ;
- node.send(msg)
- })
- });
-
-
+ whatsappLiteEvents = whatsappLiteEvents?.split(",") || whatsappLiteEvents;
+ whatsappLiteEvents?.forEach((waEvent)=>{
+ if (waEvent ==='messages.upsert'){
+ client.ev.on('messages.upsert', msgs =>{
+ msgs.messages.forEach(async msg =>{
+ msg.payload = msg.message?.conversation;
+ msg.from = msg.key.participant || msg.key.remoteJid;
+ msg.from = msg.from.replace(/\D/g, '') || msg.from;
+ msg.chatID = msg.key.remoteJid.replace(/\D/g, '') || msg.key.remoteJid ;
+ node.send(msg)
+ })
+ });
+ }
+ else {
+ client.ev.on(waEvent, msgs =>{
+ node.send(msgs)
+ });
+
+ };
+ })
+
+
//Setting conncetion status indication
client.ev.on('connection.update', (updates)=>{
var {connection} = updates
@@ -80,14 +102,7 @@ module.exports = function(RED) {
}
clientFromWhatsappLite();
-
-
-
-
-
-
- }
-
+ };
}
RED.nodes.registerType("chats-in", WhatsappIn);
}
diff --git a/chats-out.html b/chats-out.html
index 6928a9f..fa1cb9d 100644
--- a/chats-out.html
+++ b/chats-out.html
@@ -54,5 +54,64 @@ MultiMedia Message Out: Requirments-
| `msg.payload` | Image Caption |
| `msg.toNumber` | Reciver number (if number not provided in node) |
+
+## Button, List and TemplateButton
+Supported in Whatsapp-Lite only, `TODO for Whatsapp-Web`.
+
+* Simple Button For simple 3 Bottons your `msg.paylod` should be...
+
+```js
+msg.payload = {
+ text: "Hi it's button message", //String
+ footer: 'Hello World', //String
+ headerType: 1, //keep it "1" only.
+ buttons: [ // Array of buttons.
+ {buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1},
+ {buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1},
+ {buttonId: 'id3', buttonText: {displayText: 'Button 3'}, type: 1}
+ ]
+}
+```
+* TemplateButton combination of link button, Call button and Normal buttons. Your `msg.paylod` should look similar to--
+
+```js
+msg.payload = {
+ text: "Hi it's a template message by Node-RED 👍 to Test",
+ footer: 'Hello I am footer of message.',
+ templateButtons: [
+ {index: 1, urlButton: {displayText: '⭐ Vist Node-RED', url: 'https://nodered.org/'}},
+ {index: 2, callButton: {displayText: 'Call me!', phoneNumber: '+1 (234) 5678-901'}},
+ {index: 3, quickReplyButton: {displayText: 'Click me I am Button', id: 'I-am-button-id-without-space'}},
+ {index: 4, quickReplyButton: {displayText: '🖱️ Sample Button 2', id: 'button-2-was-clicked'}}
+ ]
+}
+```
+* List Message combination of link button, List button and Selectors. Your `msg.paylod` should look similar to--
+
+```js
+msg.payload = {
+ text: "This is a list",
+ footer: "nice footer, link: https://google.com",
+ title: "Amazing boldfaced list title",
+ buttonText: "Required, Tap to see List",
+ sections : [{
+ title: "Section 1",
+ rows: [
+ {title: "Option 1", rowId: "option1"},
+ {title: "Option 2", rowId: "option2", description: "This is a description"}
+ ]},
+ {
+ title: "Section 2",
+ rows: [
+ {title: "Option 3", rowId: "option3"},
+ {title: "Option 4", rowId: "option4", description: "This is a description V2"}
+ ]
+ }]
+}
+
+```
+Yes its lot require for buttons, A node will come soon to minimize these effors.
+You may direct import these test button with bellow code.
+
-*Don't forget to mention international dialing code befor your number. Number must be in format like `+11 99999 99999` without any space.*
diff --git a/package.json b/package.json
index d619921..67ea637 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-whatsapp-link",
- "version": "0.1.32-B",
+ "version": "0.1.34",
"description": "Node to send and receive whatsapp messages in groups and chats. | No third party APIs",
"repository": {
"type": "git",
@@ -31,8 +31,8 @@
},
"dependencies": {
"@adiwajshing/baileys": "latest",
- "qrcode": "^1.5.1",
- "whatsapp-web.js": "latest"
+ "whatsapp-web.js": "latest",
+ "qrcode": "^1.5.1"
},
"engines": {
"node": ">=8.0.0"