79275408

Date: 2024-12-12 14:10:18
Score: 3.5
Natty:
Report link

Your question has two distinct parts, and the second one is more tricky/complex as it depends on the architecture you want to implement. Please provide more design info, so we can assist you better.

Is there a way to overcome the limitation of adding multiple phone numbers to a single WhatsApp Business Account?

Yes, you need to Verify Your Business. Once verified, you can add more business numbers. Follow Meta's instructions here: Meta Business Verification

How can I support 70 tenants, each with a unique phone number and WhatsApp bot, using the WhatsApp Business Cloud API?

This depends on the architecture and programming language you’re using. Here’s a scalable approach to handle this scenario in a multi-tenant setup:

Message Gateway:

import redis

redis_client = redis.StrictRedis()

def enqueue_message(message):
    tenant_id = message["metadata"]["phone_number_id"]  # Unique for each WhatsApp number
    queue_name = f"queue:{tenant_id}"
    redis_client.rpush(queue_name, message)

Worker:

import time

def processor_1(tenant_id, message):
    print(f"First Processor {tenant_id}: {message}")

def processor_2(tenant_id, message):
    print(f"Second Processor {tenant_id}: {message}")

def worker(tenant_id):
    queue_name = f"queue:{tenant_id}"
    while True:
        message = redis_client.lpop(queue_name)
        if message:
            if tenant_id == "foo": 
                processor_1(tenant_id, message)
            else:
                processor_2(tenant_id, message)
        else:
            time.sleep(1)  # No messages, wait and retry

This is a simplified example. For a more comprehensive implementation (and I run in production), you can refer to this example:

Whatsapp Message Gateway + Multiple workers Example

Reasons:
  • Blacklisted phrase (0.5): How can I
  • Blacklisted phrase (1): Is there a way
  • RegEx Blacklisted phrase (2.5): Please provide
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Sergio Gao