How to ban numbers in my WhatsApp chatbot

Hey folks,

I prepared a simple WhatsApp chatbot in n8n. Now I want to ban some number so so they don’t get a reply.

What I’d like to achieve is:

If a banned number sends a message, it should still trigger the WhatsApp node, but not be passed forward to the AI Agent (basically stop the workflow at that point).

Alternatively, is it possible to not even trigger the WhatsApp On Message trigger when the sender is in the ban list?

Either solution is appreciated. Thanks!

let me help you on that

Hey @milola welcome to the community.

To achieve your goal of blocking specific WhatsApp numbers from triggering your n8n workflow or receiving replies from your AI Agent, you can implement this solution.

  1. Before the AI Agent node, add an “If” node to check if the sender’s number is in your ban list.
  2. Set up the condition to check if the sender’s number matches any number in your ban list. If true, stop the workflow.
  3. Connect the “If” node to a node that stops the workflow execution, ensuring the AI Agent node isn’t triggered.

You can maintain your ban list as an external data source, such as a Google Sheet or a database, and use an “HTTP Request” node or a database node to fetch and check the list in your workflow.

Here’s an example of how your workflow can look like.

  1. WhatsApp trigger node, Triggers the workflow when a message is received.
  2. If Node” Checks if the sender’s number is in the ban list. If yes, stops the workflow.
  3. AI Agent Node Processes the message and responds if the sender’s number isn’t banned.

Hope this helps.

6 Likes

you can do something like this

you can hardcode your ban number inside the array in the code node

place this nodes after your whatsapp trigger and connect the false branch to your rest of your workflow

hope it helps!

2 Likes
1 Like

Thank you for this