Comments (7)
Hey @esteves67 , I've made some changes in wBotMesasgeListener to handle messages that was not sent from frontend app.
At the time it only works for chat messages (media messages will result in blank messages or big base64 hashes in message body), but for "auto response proposals" it works well.
Let me know if it works for you, so I can close this issue.
from whaticket-community.
Hi, Steeve!
You're right, the system doesn't handle messages that not wasn't sent from frontend.
There are two files in code interacting with Whatsapp-Web.js to send and receive messages:
backend/src/services/wbotMessageListener.js
: listen for received messages, store then in database, update ticket last message and send it with websockets to frontend.
backend/src/controllers/MessageController.js
: receive a POST request from frontend, send message with WWebJS, store it in DB, update ticket last message and send it with websockets to frontend.
The event wbot.on("message" ,...)
only listen to other people messages. To handle our own messages (sent directly from cellphone or even with WWebJS), we could use wbot.on("message_create, ...)
, that listen to all messages in chat, including ours. But its no so simples because it will result in duplicate messages and break other things, like file upload.
I'm currently working a better way to handle it, and I will address the solution to cover your auto response too.
Thanks for the feedback!
from whaticket-community.
Again, thank you for the Whaticket Client! You made a solution for what WPP is taking ages to do (multiple users on a single phone number).
from whaticket-community.
Hey @esteves67 , I've made some changes in wBotMesasgeListener to handle messages that was not sent from frontend app.
At the time it only works for chat messages (media messages will result in blank messages or big base64 hashes in message body), but for "auto response proposals" it works well.
Let me know if it works for you, so I can close this issue.
Working flawless! Now the chat is returning and showing auto-respond messages sent by my bot to the person who i am attending!
from whaticket-community.
Hi, Steeve!
You're right, the system doesn't handle messages that not wasn't sent from frontend.
There are two files in code interacting with Whatsapp-Web.js to send and receive messages:
backend/src/services/wbotMessageListener.js
: listen for received messages, store then in database, update ticket last message and send it with websockets to frontend.
backend/src/controllers/MessageController.js
: receive a POST request from frontend, send message with WWebJS, store it in DB, update ticket last message and send it with websockets to frontend.The event
wbot.on("message" ,...)
only listen to other people messages. To handle our own messages (sent directly from cellphone or even with WWebJS), we could usewbot.on("message_create, ...)
, that listen to all messages in chat, including ours. But its no so simples because it will result in duplicate messages and break other things, like file upload.I'm currently working a better way to handle it, and I will address the solution to cover your auto response too.
Thanks for the feedback!
Thank your for the explanation on how the process works, it clarified for me how everything works since im not a experiencied javascript developer 😄
from whaticket-community.
Hi, Steeve!
You're right, the system doesn't handle messages that not wasn't sent from frontend.
There are two files in code interacting with Whatsapp-Web.js to send and receive messages:
backend/src/services/wbotMessageListener.js
: listen for received messages, store then in database, update ticket last message and send it with websockets to frontend.
backend/src/controllers/MessageController.js
: receive a POST request from frontend, send message with WWebJS, store it in DB, update ticket last message and send it with websockets to frontend.The event
wbot.on("message" ,...)
only listen to other people messages. To handle our own messages (sent directly from cellphone or even with WWebJS), we could usewbot.on("message_create, ...)
, that listen to all messages in chat, including ours. But its no so simples because it will result in duplicate messages and break other things, like file upload.I'm currently working a better way to handle it, and I will address the solution to cover your auto response too.
Thanks for the feedback!
Hello again! 😄
Not the best approach or solution since i started in nodeJS just 1 month ago, but i think it worked for me:
- tested in localhost and just 1 person sending message to the bot
- not tested yet in a real "environment" or real situation with more than 1 person sending message at the same time,
How to: Make changes in Message.js like code bellow:
Also use wbot.on("message_create, ...)
in the wbotMessageListener.js.
/**
* Indicates if the message was sent by the current user
* @type {boolean}
*/
this.fromMe = data.id.fromMe;
/**
* ID for the Chat that this message was sent to, except if the message was sent by the current user.
* @type {string}
*/
if (this.fromMe == true) {
this.from = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
this.to = (typeof (data.from) === 'object' && data.from !== null) ? data.from._serialized : data.from;
} else if (this.fromMe == false) {
this.from = (typeof (data.from) === 'object' && data.from !== null) ? data.from._serialized : data.from;
this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
}
/**
* ID for who this message is for.
*
* If the message is sent by the current user, it will be the Chat to which the message is being sent.
* If the message is sent by another user, it will be the ID for the current user.
* @type {string}
*/
/**
* If the message was sent to a group, this field will contain the user that sent the message.
* @type {string}
*/
this.author = (typeof (data.author) === 'object' && data.author !== null) ? data.author._serialized : data.author;
from whaticket-community.
Nice job, @esteves67 ! It may work. But I wouldn't change the WWebJS code directly, since all your changes will be lost in case of an update.
I'll keep this issue open, since my plan is to support this feature soon.
from whaticket-community.
Related Issues (20)
- qr does not connect, it could be that whatsapp blocked the qr HOT 24
- Error Build Frontend HOT 2
- updated whatsapp-web.js - 1.23.0 after not working HOT 8
- Stickers não aparecem embaixo da mensagem - Reação por Emoji HOT 1
- send broadcast message HOT 1
- pending kernel upgrade HOT 2
- Installation error HOT 2
- Erro na leitura do QRCode HOT 2
- The connection menu appears an exclamation mark
- Error appears after running npm run build HOT 4
- Add SQLite support
- QR Error never connects HOT 9
- Error from backend docker image (lodash) HOT 2
- Acabei de baixar o código do GIT HOT 1
- qr does not connect, HOT 2
- Filtering problems
- npm run build show errors
- Ubuntu 22 e instalacao
- Conversa nao aparece HOT 4
- Não gera o modal do QR Code para conectar o Whatsapp HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whaticket-community.