base64 Image support added
This commit is contained in:
parent
dcf46cde9c
commit
176b51ec9a
@ -1,6 +1,7 @@
|
||||
# Whatsapp Link :iphone:
|
||||
|
||||
Simple node for connecting Node-Red to Whatsapp :iphone:
|
||||
Send and Receive Whatsapp Image/Text.
|
||||
|
||||
Currently in developing mode, Continous updated may encounter. :sweat_smile:
|
||||
|
||||
@ -65,12 +66,12 @@ Admin Node generate QR Code just below the node for easy connection with whatsap
|
||||
|
||||
|
||||
3. **Chats / Group Out** : As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node.
|
||||
`A-reply-to-All.json` example is avilable in examples to import.
|
||||
`ImageMessage.json` example is avilable in examples to import.
|
||||
|
||||
MultiMedia Message: Requirments-
|
||||
| Input | Description |
|
||||
|--------|-------------|
|
||||
| `msg.image` | Base64 (encoded image) |
|
||||
| `msg.image` | Base64 (encoded image), [`image-tool`](https://flows.nodered.org/node/node-red-contrib-image-tools) node work fine|
|
||||
| `msg.payload` | Image Caption |
|
||||
| `msg.toNumber` | Reciver number (if number not provided in node) |
|
||||
|
||||
@ -144,6 +145,7 @@ msg.payload = {
|
||||
Yes its lot require for buttons, A node will come soon to minimize these effors.
|
||||
You may direct import these test buttons from the Node Examples.
|
||||
|
||||
`A-reply-to-All.json` example is avilable in examples to import.
|
||||
|
||||
5. **Reply Node** : In Beta mode. (Chats-out Node can be used instead of reply node)
|
||||
|
||||
@ -163,7 +165,7 @@ Issues and Suggestions are welcome [here.](https://github.com/raweee/node-red-co
|
||||
* `Ver-0.1.34` : Multiple Events reading options are added in Chats-In Node.
|
||||
* `Ver-0.1.36` : Check box added to show status as `Online/Offline` in Whatsapp-Link Node, to get push notifications. Ping-Interval added to keep whatsapp alive for long time. Multiple examples added.
|
||||
* `Ver-0.1.37` : Changes for correction of send message with images and use Chromium profiles in Puppeteer.
|
||||
* `Ver-0.1.39A` : Broken "Whatsapp-Web & Lite" fixed. Able to recive and send text. working on easy to use nodes.
|
||||
* `Ver-0.1.39B` : Broken "Whatsapp-Web & Lite" fixed. Able to `Send/Receive` whatsapp `Image/Text` in both Whatsapp-Lite & Web. working on easy to use nodes.
|
||||
|
||||
## Future Nodes
|
||||
Currently working on more Whatsapp Node and will be avilable soon -
|
||||
|
||||
2
admin.js
2
admin.js
@ -72,7 +72,7 @@ module.exports = function(RED) {
|
||||
msg.type = notification.type;
|
||||
msg.notification = notification;
|
||||
node.send(msg);
|
||||
notification.reply('!Node-Red joined');
|
||||
// notification.reply('!Node-Red joined');
|
||||
});
|
||||
|
||||
node.client.on('group_leave', async (notification)=>{
|
||||
|
||||
18
chats-out.js
18
chats-out.js
@ -5,7 +5,8 @@ module.exports = function(RED) {
|
||||
node.number = config.number;
|
||||
var whatsappLinkNode = RED.nodes.getNode(config.whatsappLink);
|
||||
node.waClient = whatsappLinkNode.client;
|
||||
const { MessageMedia, Buttons } = require('whatsapp-web.js')
|
||||
const { MessageMedia, Buttons } = require('whatsapp-web.js');
|
||||
const {Mimetype} = require(`@whiskeysockets/baileys`);
|
||||
|
||||
let SetStatus = function(WAStatus, color){
|
||||
node.status({fill:color,shape:"dot",text:WAStatus});
|
||||
@ -75,6 +76,7 @@ module.exports = function(RED) {
|
||||
async function whatsappMultiMediaMessage(numb, whatsappImage, whatsappCaption){
|
||||
whatsappCaption = whatsappCaption || "Image from Node-Red";
|
||||
var whatsappImageBase64 = whatsappImage.split(',')[1] || whatsappImage;
|
||||
console.log(whatsappImageBase64)
|
||||
try {
|
||||
if (node.waClient.clientType === "waWebClient"){
|
||||
numb = await webNubmerSeteing(numb)
|
||||
@ -83,12 +85,14 @@ module.exports = function(RED) {
|
||||
}
|
||||
else {
|
||||
numb = await socNubmerSeteing(numb)
|
||||
const imageMessage = {
|
||||
text: whatsappCaption,
|
||||
footer: null,
|
||||
templateButtons: null,
|
||||
image: {url : whatsappImage }
|
||||
};
|
||||
|
||||
let imageToSend = Buffer.from(whatsappImageBase64, "base64");
|
||||
const imageMessage = {
|
||||
// image: {url : whatsappImage},
|
||||
image: imageToSend,
|
||||
caption: whatsappCaption
|
||||
}
|
||||
|
||||
let client = await node.waClient;
|
||||
const msgStatus = await client.sendMessage(numb, imageMessage);
|
||||
}
|
||||
|
||||
139
examples/ImageMessage.json
Normal file
139
examples/ImageMessage.json
Normal file
File diff suppressed because one or more lines are too long
18
group-out.js
18
group-out.js
@ -76,21 +76,23 @@ module.exports = function(RED) {
|
||||
};
|
||||
|
||||
async function whatsappMultiMediaMessage(numb, whatsappImage, whatsappCaption){
|
||||
var whatsappImageBase64 = whatsappImage.split(',')[1] || whatsappImage;
|
||||
try {
|
||||
if (node.waClient.clientType === "waWebClient"){
|
||||
numb = await webNubmerSeteing(node.number)
|
||||
var whatsappImageBase64 = whatsappImage.split(',')[1] || whatsappImage;
|
||||
var myMessage = new MessageMedia('image/png', whatsappImageBase64, null, null);
|
||||
node.waClient.sendMessage(numb, myMessage, {caption : whatsappCaption || "Image from Node-Red"});
|
||||
}
|
||||
else {
|
||||
numb = await socNubmerSeteing(node.number)
|
||||
const imageMessage = {
|
||||
text: whatsappCaption,
|
||||
footer: null,
|
||||
templateButtons: null,
|
||||
image: {url : whatsappImage }
|
||||
};
|
||||
numb = await socNubmerSeteing(node.number);
|
||||
|
||||
let imageToSend = Buffer.from(whatsappImageBase64, "base64");
|
||||
const imageMessage = {
|
||||
// image: {url : whatsappImage},
|
||||
image: imageToSend,
|
||||
caption: whatsappCaption
|
||||
}
|
||||
|
||||
let client = await node.waClient;
|
||||
const msgStatus = await client.sendMessage(numb, imageMessage);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-contrib-whatsapp-link",
|
||||
"version": "0.1.39A",
|
||||
"version": "0.1.39B",
|
||||
"description": "Node to send and receive whatsapp messages in groups and chats. | No third party APIs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user