-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(chat): add whatsapp number check guardrails #2581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nikolasdehor
wants to merge
3
commits into
evolution-foundation:develop
Choose a base branch
from
nikolasdehor:abuse-safety-whatsappnumbers-guardrails
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Responsible Messaging And Deliverability | ||
|
|
||
| Evolution API is a messaging infrastructure project. Operators are responsible | ||
| for following WhatsApp and Meta policies, collecting opt-in consent, respecting | ||
| opt-out requests, and avoiding unsolicited or high-volume messaging. | ||
|
|
||
| This guide documents guardrails that reduce accidental bursts and make risky | ||
| usage easier to identify. They are not anti-ban features, do not bypass platform | ||
| enforcement, and do not guarantee message delivery. | ||
|
|
||
| ## WhatsApp Number Checks | ||
|
|
||
| The `/chat/whatsappNumbers/{instance}` endpoint can call WhatsApp Web through | ||
| Baileys when a number is not already cached. Large uncached batches create a | ||
| burst of platform checks from a single instance. | ||
|
|
||
| Evolution API limits and chunks these checks by default: | ||
|
|
||
| ```env | ||
| ABUSE_SAFETY_WHATSAPP_NUMBERS_MAX_BATCH_SIZE=50 | ||
| ABUSE_SAFETY_WHATSAPP_NUMBERS_QUERY_BATCH_SIZE=10 | ||
| ABUSE_SAFETY_WHATSAPP_NUMBERS_QUERY_BATCH_INTERVAL_MS=1000 | ||
| ``` | ||
|
|
||
| When a request exceeds `ABUSE_SAFETY_WHATSAPP_NUMBERS_MAX_BATCH_SIZE`, the API | ||
| returns `429 Too Many Requests` with a `Retry-After` header and a structured | ||
| response that includes the configured limit. | ||
|
|
||
| The chunk interval only adds backpressure between direct Baileys checks. Cached | ||
| numbers, groups, broadcasts, and newsletters do not require the same Baileys | ||
| lookup path. | ||
|
|
||
| ## Responsible Operation | ||
|
|
||
| - Use WhatsApp Business Platform / Cloud API for production business messaging | ||
| when possible. | ||
| - Send messages only to contacts who have explicitly opted in. | ||
| - Provide and honor opt-out flows. | ||
| - Keep batch sizes bounded and monitor failures, pending delivery, and user | ||
| complaints. | ||
| - Treat `delay` as application pacing only. It does not guarantee delivery, | ||
| account safety, or policy compliance. | ||
|
|
||
| ## Out Of Scope | ||
|
|
||
| The guardrails in this project intentionally do not implement proxy rotation, | ||
| IP rotation, fingerprint randomization, automated warmup, human-like behavior | ||
| simulation, or guarantees that an account will not be restricted. | ||
|
|
||
| ## References | ||
|
|
||
| - Community report about `/chat/whatsappNumbers` bulk check risk: | ||
| https://github.com/evolution-foundation/evolution-api/issues/2228 | ||
| - Community discussion about constant bans and high-volume sending: | ||
| https://github.com/evolution-foundation/evolution-api/issues/1870 | ||
| - High-volume queue/rate-limit question closed as usage support: | ||
| https://github.com/evolution-foundation/evolution-api/issues/2538 | ||
| - Deliverability reports with pending/one-tick messages: | ||
| https://github.com/evolution-foundation/evolution-api/issues/1854 | ||
| https://github.com/evolution-foundation/evolution-api/issues/2404 | ||
| - WhatsApp Business Messaging Policy: | ||
| https://whatsappbusiness.com/policy/ | ||
| - WhatsApp Business Terms: | ||
| https://www.whatsapp.com/legal/business-terms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { HttpStatus } from '@api/routes/index.router'; | ||
|
|
||
| export class TooManyRequestsException { | ||
| constructor(retryAfter?: number, ...objectError: any[]) { | ||
| throw { | ||
| status: HttpStatus.TOO_MANY_REQUESTS, | ||
| error: 'Too Many Requests', | ||
| retryAfter, | ||
| message: objectError.length > 0 ? objectError : undefined, | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.