Closed odv1983 closed 1 year ago
i´ve search for the command window.Store.MediaPrep.prepRawMedia but it is undefined, what i tried: put puppeteer config to:
puppeteer : {
headless : false,
args : ['--no-sandbox', '--disable-setuid-sandbox']
}
in whatsappLink.js in order to enter the console and search for the function but it is undefined, that´s the reason why it is failing i suppose
Hi @odv1983, can you please explain your changes. It will be helpful
Hi @odv1983, can you please explain your changes. It will be helpful
Yes. (I'm using google translator).
In whatsappLink.js I include '''--user-data-dir=' + node.id" as a parameter for puppeteer, so it uses the id of the node to create a profile for each WhatsApp connection, this way I was able to connect several WhatsApp accounts, as before one ended up disconnecting the other. In addition, I also had to install chrome and create a symbolic link within the puppeteer directory to be able to work, because with the chrome I had, it was not working.
And then inside chats-out.js I changed the parameter numb = await webNubmerSeteing(node.number), instead of node.number, I put the numb, because the numb is already handled (I don't have much knowledge of this part, but I saw that it would work), this is what solved the image upload problem for me.
I'm not an expert in programming, but I can read and adjust some things on my own when I need to, so I decided to put it here, because it's something that worked for me.
It would be great to implement this in a better way, maybe with some parameter in the node to put the profile name, or use a name for the whatsappLink.js node to define Chrome profiles.
So he doesn't mix the messages.
I reinstalled chromium as described here: https://github.com/raweee/node-red-contrib-whatsapp-link/issues/10#issuecomment-1403027612
Hi @odv1983, can you please explain your changes. It will be helpful
Yes. (I'm using google translator).
In whatsappLink.js I include '''--user-data-dir=' + node.id" as a parameter for puppeteer, so it uses the id of the node to create a profile for each WhatsApp connection, this way I was able to connect several WhatsApp accounts, as before one ended up disconnecting the other. In addition, I also had to install chrome and create a symbolic link within the puppeteer directory to be able to work, because with the chrome I had, it was not working.
And then inside chats-out.js I changed the parameter numb = await webNubmerSeteing(node.number), instead of node.number, I put the numb, because the numb is already handled (I don't have much knowledge of this part, but I saw that it would work), this is what solved the image upload problem for me.
I'm not an expert in programming, but I can read and adjust some things on my own when I need to, so I decided to put it here, because it's something that worked for me.
@odv1983 i understand the part that you change by numb, it is an error of typing i thought (node.number not even exists) please can you make a video tutorial please on how you added the version of chrome? i´m using windows right now and '''--user-data-dir=' + node.id" doesnt works, it simply crash my node-red, thanks in advice!!
By the way i put this question on: stackoverflow.com/questions/75806378/node-red-node-red-contrib-whatsapp-link @raweee your library is really helpfull i would like to contribute if you like we can make a discord channel or something like that so we can code together and improve the tool :)
Hi @jjcampis, node-red crashing because it try to open chrome with user-data-dir
. But node-red unable to find chrome.
For some machine we have to specify where the chrome is located. To avoid it, whatsappLite was created.
By the way i put this question on: stackoverflow.com/questions/75806378/node-red-node-red-contrib-whatsapp-link @raweee your library is really helpfull i would like to contribute if you like we can make a discord channel or something like that so we can code together and improve the tool :)
I can't make a video right now, but I used this link to install chromium and it worked for me. I use Linux Debian 10 and my nodered runs in Docker container. Link: https://github.com/raweee/node-red-contrib-whatsapp-link/issues/10#issuecomment-1403027612
Ideally, use some node name, you need to see how to pass this parameter to create another instance of Chrome/Chromium on windows, as if using browser profiles normally.
I hope it helps you.
Hi @jjcampis, node-red crashing because it try to open chrome with
user-data-dir
. But node-red unable to find chrome. For some machine we have to specify where the chrome is located. To avoid it, whatsappLite was created.
With whatsappLite is it possible to connect multiple WhatsApp accounts as well? The way I've done it here, I'm using 9 accounts with no problem, but with the web.
Yes @odv1983, whatsappLite (sockets) also supports multi users. It is lite in ram and doesn't require chrome. A little change in code will activate this functionality to user.
Hi @jjcampis, node-red crashing because it try to open chrome with
user-data-dir
. But node-red unable to find chrome. For some machine we have to specify where the chrome is located. To avoid it, whatsappLite was created.
thanks, i tried to use whatsapp lite, but i don't know how... the chromium is opened and works well.... with messages but with multimedia it crash, i know that it opens because i turned headless to false. right now i'm in the job but when i get home i will give it a try
Each ID of this is a chromium profile folder that puppeteer created.
Hi @odv1983, right now I'm merging the pull request with main branch. Will start new thread for multiUser support in lite version.
Yes @odv1983, whatsappLite (sockets) also supports multi users. It is lite in ram and doesn't require chrome. A little change in code will activate this functionality to user.
How can I activate? I tried it on whatsappLite but it got the messages mixed up. That's why I walked to the web and made this workaround.
Hi @odv1983, right now I'm merging the pull request with main branch. Will start new thread for multiUser support in lite version.
Excelent! Congratulations.
We can even use user define name
instead of node-id, will work on it also.
@raweee when you re going to release the version for install in nodered... i tried the lite version, it doesnt send the images (finally throws me the qr the lite version) i keep trying, it seems like it is a question of puppeteer or something
@odv1983 i have a doubt chats-out.js depends on what you have changed on whatsapp-link.js in order to work? i think is something to do with puppeteer if not
i have a doubt chats-out.js depends on what you have changed on whatsapp-link.js in order to work? i think is something to do with puppeteer if not
it doesn't depend, the change in chats-out is to send messages with image, the change in whatsapp-link is to connect more than 1 instance of whatsapp using puppeteer without mixing the messages.
i have a doubt chats-out.js depends on what you have changed on whatsapp-link.js in order to work? i think is something to do with puppeteer if not
it doesn't depend, the change in chats-out is to send messages with image, the change in whatsapp-link is to connect more than 1 instance of whatsapp using puppeteer without mixing the messages.
ok i don´t need for multiple instances yet... it would be nice, but right now i need to send images and i can´t :( with webwhatsapp it says: window.Store.MediaPrep.prepRawMedia is not a function as the image that i posted before... i have updated the web-whatsapp.js i don´t know what else to try
For image, I'll try to fix it today if possible after my office hrs or tomorrow.
For image, I'll try to fix it today if possible after my office hrs or tomorrow.
@raweee if you want we can have a meeting on discord, i´ve created a server so we can chat directly or stream on live and help each other...
link to join: https://discord.gg/wfEQgeC3
For Image : use whats-app Web, image will work fine. Here is simple example to send image file.
[
{
"id": "2847001ac56bad89",
"type": "inject",
"z": "02791882872c8aba",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "toNumber",
"v": "",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "https://raw.githubusercontent.com/raweee/node-red-contrib-whatsapp-link/main/.github/WhatsaaLite.png",
"payloadType": "str",
"x": 130,
"y": 80,
"wires": [
[
"6ea288a24b2865e7"
]
]
},
{
"id": "6ea288a24b2865e7",
"type": "jimp-image",
"z": "02791882872c8aba",
"name": "",
"data": "payload",
"dataType": "msg",
"ret": "b64",
"parameter1": "",
"parameter1Type": "msg",
"parameter2": "",
"parameter2Type": "msg",
"parameter3": "",
"parameter3Type": "msg",
"parameter4": "",
"parameter4Type": "msg",
"parameter5": "",
"parameter5Type": "msg",
"parameter6": "",
"parameter6Type": "msg",
"parameter7": "",
"parameter7Type": "msg",
"parameter8": "",
"parameter8Type": "msg",
"sendProperty": "image",
"sendPropertyType": "msg",
"parameterCount": 0,
"jimpFunction": "none",
"selectedJimpFunction": {
"name": "none",
"fn": "none",
"description": "Just loads the image.",
"parameters": []
},
"x": 230,
"y": 140,
"wires": [
[
"d123816d42bc2ca5"
]
]
},
{
"id": "d123816d42bc2ca5",
"type": "chats-out",
"z": "02791882872c8aba",
"name": "Chats Out",
"whatsappLink": "73c23c9515ee8330",
"number": "",
"x": 340,
"y": 200,
"wires": []
},
{
"id": "73c23c9515ee8330",
"type": "whatsappLink",
"cName": "whatsapp-web",
"name": "Web",
"clientType": "waWebClient",
"onlineStatus": true,
"loopTime": "5"
}
]
it seems like it´s a flow to import right? it says that doesn´t register de jim input, i searched and installed this one: node-red-contrib-viseo-jimp it is ok? or am i missing something??
Image file must in base64
. You can use contrib-image-tool
to convert any image. This node is image helping node only.
If your image is already base64, no requirement of image-tool
.
Image file must in
base64
. You can usecontrib-image-tool
to convert any image. This node is image helping node only. If your image is already base64, no requirement ofimage-tool
.
thanks! i found the right one i think because the flow.json worked with this one -> node-red-contrib-image-tools
but... it keeps throwing this:
Evaluation failed: TypeError: window.Store.MediaPrep.prepRawMedia is not a function
at Object.window.WWebJS.processMediaData (__puppeteer_evaluation_script__:235:50)
i think it is something more related on puppeteer than the library itself... i don´t know
Image file must in
base64
. You can usecontrib-image-tool
to convert any image. This node is image helping node only. If your image is already base64, no requirement ofimage-tool
.thanks! i found the right one i think because the flow.json worked with this one -> node-red-contrib-image-tools
but... it keeps throwing this:
Evaluation failed: TypeError: window.Store.MediaPrep.prepRawMedia is not a function at Object.window.WWebJS.processMediaData (__puppeteer_evaluation_script__:235:50)
i think it is something more related on puppeteer than the library itself... i don´t know
Image file must in
base64
. You can usecontrib-image-tool
to convert any image. This node is image helping node only. If your image is already base64, no requirement ofimage-tool
.thanks! i found the right one i think because the flow.json worked with this one -> node-red-contrib-image-tools
but... it keeps throwing this:
Evaluation failed: TypeError: window.Store.MediaPrep.prepRawMedia is not a function at Object.window.WWebJS.processMediaData (__puppeteer_evaluation_script__:235:50)
i think it is something more related on puppeteer than the library itself... i don´t know
DONE!!!!! After a LOT of research behind... it has in effect to do with the whatsapp-web.js library in this post: same conversation above you can see how the function is undefined, i wa trying to reach where that function is called because in the inspector i cant see it but the function that exists is: prepRawMedia
I found the solution here: go to solution
BASICALLY YOU HAVE TO EDIT THIS: archive: node_modules/whatsapp-web.js/src/util/Injected.js
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0]; //find this line window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0]; //replace with this
If you just update your nodes, it will work fine. No need for editing in injected.js.
It was already resolved in updated version.
It worked here for me. I was also having trouble sending images with whatsappWeb.
keep trying...
21 Mar 15:03:59 - [red] Uncaught Exception: 21 Mar 15:03:59 - [error] Error: Evaluation failed: TypeError: window.Store.MediaPrep.prepRawMedia is not a function at Object.window.WWebJS.processMediaData (__puppeteer_evaluation_script__:235:50) at async Object.window.WWebJS.sendMessage (__puppeteer_evaluation_script__:19:19) at async __puppeteer_evaluation_script__:10:25 at ExecutionContext._evaluateInternal (C:\Users\JJ\.node-red\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19) at runMicrotasks (<anonymous>) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ExecutionContext.evaluate (C:\Users\JJ\.node-red\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16) at async Client.sendMessage (C:\Users\JJ\.node-red\node_modules\whatsapp-web.js\src\Client.js:686:28)
thats in the console of nodered, i think puppeteer seems to be the problem....