#Not getting banned (or at least trying not to)
1 messages · Page 1 of 1 (latest)
WWebJS run a real instance of Whatsapp Web to avoid getting blocked. Just try not to send too many messages at once max 1 per second. Otherwise, everything is quite flexible, but you shouldn't exaggerate it
before doing anything ask yourself "would a regular whatsapp user do this?" if not you're likely to get identified as a bot and banned
I got a 3 seconds delay after each text. So far i have sent 20k plus texts
Treat it like a real Whatsapp instance
If you got a bot to reply to someone’s text, don’t immediately reply. Wait for a second or two before responding
Just like a real human
And if it’s making you money look into getting api
I am working on getting one soon
I do something like you, but never the same delay beteween messages... I add some extra stuffs:
-
Random "Sleep" time between 1 to 4 seconds, but in milisecs... so i get a random value between 1.000 and 4.000 to wait.
-
Our product is prior to ANSWER previous contacts, so 99% of the time, the our app receive the first message from the users; and only then we reply.
-
We use the rule 1-1-1... 1 Whatsapp number - 1 Client per instance - 1 One IP unique address. So if some numer got a ban, it will not affect others
-
As our bot is a "gateway" to messages, it works as a intermediate server. So when it receive a message, it will send it to the definitive server, and the server will show to the support staff, and this will take some seconds. Some msgs got answered in a few seconds, others can take a long time; so our app works as close to a real whatsapp web, but with a lot of attendants at the same time
I am using amocrm for customer communication and bots
Then i did a lot of automation using this library
That includes order processing
And payment links
Really like this stuff
Don’t wanna move to official api
Cos of 24 hr pricing limit for business initiated services
But we have to at one point
My app send messages in a queue, and the queued task to send message is configured to have no parallel tasks just one. So, first i send the message, then add a random "Sleep" time, and after the sleep runs; i end the task to another get to the queue
I like this idea
What you are using for random?
Ps: not a js guy, i learnt js just for this library
And any suggestions on running chatbots using this code?
With like redis stream
To treat customer ls in conversations instead of new message
const min = 1000
const max = 4000
const t = Math.floor(Math.random() * (min - max)) + max;
await sleep(t);
async sleep(ms) {
await new Promise((resolve) => setTimeout(resolve, ms))
}
Something like this
Awesome thanks
I created a function for sleep and using it in all
Will send the snippet when i am home
as i am using miliseconds, there are 3.000 possible interval options. So it will make it close to a human behavior
I like to use the my sleep with a promise, because i it turns the result asynchronous then i can await it and lock the execution flow until the sleep time ends.
@jagged eagle any idea on this?
i don't understand what do you mean here
Basically a chat bot
Suppose someone sends a message
And bot replies with welcome
And convo proceeds
Instead of triggering the first message again
Basically a session servixe
give me some minutes
client.on('message', async (msg) => {
if(msg.body === "Hey, can you help me!"){
await sleepRandom();
msg.reply('Of course i can help you');
// Do not use then.
sleepRandom()..then(async () => {
msg.reply('Of course i can help you');
})
}
if(msg.body === "Another option"){
// sleep, then send, etc
}
})
async sleepRandom() {
const min = 1000;
const max = 4000;
const ms = Math.floor(Math.random()*(min-max))+max;
await new Promise((resolve) => setTimeout(resolve, ms))
}
Something like this code
It shouldn’t be msg body specific
Something like this
Of course, you can send the answer option to a queued task using redis, RabbitMQ, etc...
Welcome to company, ple enter your name
Second enter your city
the msg.body is just a single example on how to get it to answer and explain the use of sleep
I see
yeah, just like i told hyou
- get the content of the msg you receive. It is on the body
- inspect the values with options you need to reply
- Give some random delay before answer
my code shows this to you
In this case, i suggest you to store the flow in some database. So you can check the last received message content and the answer you send.
Makes sense
I am currently using dynamodb
For storing some data
And you can add a TTL, Time To Live... a time to the option expires
So you can restart the flow
there are infinite options. You need to enumerate what you need first, then create your rules
The example i give you is just a single exercise explaining how to use
Look at the part i comment, DO NOT USE .then... use await
this is an asynchronous 101 lesson
Here is what my crm does with whatsapp web
I wanna do similar using code
For some internal staff
when you do something like this:
// Some code before
someAsyncFunctionCall().then(etc)
// Some code after the call
You WILL NOT LOCK THE EXECUTION FLOW and your code will continue to execute... and when its done, will execute the .then
But if you do something like this
// Some code before
await someAsyncFunctionCall()
// now execute the etc portion after the async done
// Some code after the call
Here YOU WILL LOCK THE EXECUTION FLOW and your code ONLY will continue to execute after the async call ends
So, if you use the async call to the sleep func with then, and have a lot of messages... the sleep will work, but a lot of these messages will be sent with a short sleep in parallel. But with await you will be guaranteed to only continue after finishing the current sleep, JUST ONE, not 50 with short delay
1-5 seconds is wait is all good
Of course, inside the client messagelistener is not the right place to this. Here first i store the msg in a database, then run a queued job to proccess it. And is one bu one
cool. Is fine
Lemme dig in on this weekend
I am a system admin guy
Starting programming earlier this year lol
I'm only use dynamic random sleep duration based on text length.
if (typeof content === 'string') {
const chat = await <Client>.getChatById(chatId);
await chat.sendStateTyping()
const wpm = (content.split(' ').length / 90) * 60000;
if (wpm < 25000) await chat.clearState()
await new Promise((r) => setTimeout(r, wpm))
}
return this.client.sendMessage(chatId, content, options); ``` I made a way to simulate human typing, 90 words per minute (you can decrease it)
Do whatsapp check ip location and mark as bot if their client is running on aws instance far away from their phone login ?
From my location and aws region its almost 900kms. So will it make any issue. There are no nearby regions awailable for me on aws.
And i cannot create different region instances manually for all client.
If this location creates any issue, is there any fix to spoof or proxy ip for each clients to show as different location on aws instance...
Please help...
i am from Brazil and use AWS on Virginia, about 7.000Km, and of course another tel area codes
and in 27 months, so far so good
40 numbers and never got banned
of course, followinf some rules
Awesome. Thanks for the info
may I know cost you spend per month for those 40 numbers in AWS? I spend 20 numbers in 1 vps for 6 euro in Contabo
Contabo sucka
@rocky current we use 1-1-1 Rule
See rule #3
so in AWS was about $20 USD per number/server
but we are using Hetzner now aid ia about $7 each
I'm using 1 docker container for 1 number. You also using hetzner, I also using it for my primary endpoint.
Anyway thanks for sharing
@jagged eagle and what about buttons and list messages do you use it?
Nope i don't use
just send & receive messages
In terms of resources , using your statement... Can i say that Wwebjs consume quite some amount of resources
You need to restart your instance
Hi! I have a question how many people did you serve per month?
It depends, our customers have different profiles
we have customers with one number, others with 7 numbers
Some numbers have 5 new contacta asking for support per day
Others have 1.000 per day
Thanks! I am dimension a bot that will potentialy serve up to 5000 contacts, always replying their messages and with a random 2 to 4 seconds message delay. Needed to know if someone did it.
I think i did. I have customers that one number serves about 12K contacta in 3 days
And i ran a lot of chat.fetchMessages to get the last messages on each recent chat (last 3 days)... It helps capture non-sync msgs. Example: a simple disconnect and reconnect some minutes later will have messages not captured by the lib message and message_create events... And sometimes some messages até not sync right on wwweb
Excelent advice, i will store action in a db with a time and date and return to the user on the timestamp asked. (Chances are that some of the users ask to be notify at the same tiem) I will test and see if many of them ask the same hours
Becouse they will be notify 2 seconds or 500 seconds later depending on the demand of that time
understand.
I run in queue using redis and bull dashboard. and limit it by one task per message and ONLY one message at time because in a normal "desktop" use of whatsapp web, users do not send messages on different chats simultaneously. So i add this filter to send one message then another and another.
And I add a custom delay of 2 to 10 seconds (and simulate typing/recording) before send
wil definitly try redis and bull dashboard complementing with agenda and mongo db. If users askk for same time appointments will escalate to a new number
Thnaks!
Any one suggest ,what is an ideal time between two sending message so that is not included in bulk messaging?
I add a random interval between 2 and 10 seconds before send, then each message Will take a different time
Hi I am thinking my case where my users ask for a message at a given time example: 10:00 am. If i can send 1 at a time every 3 seconds i can only serve 20 users at 10:00 am the rest will recive message at 10:01:03 and so on.. Did you implemented a queque that schedules the message considerating the amount in line? Example: Schedule for 9:55am because y will have 5 min of messages to process?
Yes