pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
14.62k stars 3.48k forks source link

First Message #831

Closed JonazBR closed 2 years ago

JonazBR commented 2 years ago

shows when one is the first message from a user with the bot

PurpShell commented 2 years ago

?

KrishFX1 commented 2 years ago

He want to apply something like in WA Business. He wants to send message to the user automatically with the bot when they send their first message

tuyuribr commented 2 years ago

We have a message that comes when you first exchange your PK's: image

But you shouldn't rely on anything waweb based to do this, so make something to check this outside waweb ( like a db )

PurpShell commented 2 years ago

He want to apply something like in WA Business. He wants to send message to the user automatically with the bot when they send their first message

he can just fetchMessages, limit 2, and if he gets one then it's the 1st message

something like this:

const chat = await msg.getChat();
const messages = await chat.fetchMessages({limit: 2});
if (messages.length == 1) msg.reply("this was the 1st message in the chat!");
JonazBR commented 2 years ago

He want to apply something like in WA Business. He wants to send message to the user automatically with the bot when they send their first message

yes

PurpShell commented 2 years ago

He want to apply something like in WA Business. He wants to send message to the user automatically with the bot when they send their first message

he can just fetchMessages, limit 2, and if he gets one then it's the 1st message

something like this:

const chat = await msg.getChat();
const messages = await chat.fetchMessages({limit: 2});
if (messages.length == 1) msg.reply("this was the 1st message in the chat!");

@Jonas33235 try this.