How to Connect WhatsApp API to Odoo ERP Without Crashing Your System

Your sales team is likely running WhatsApp Web in three different browser tabs right now. Every time an order gets confirmed or an invoice is posted, someone manually downloads a PDF from Odoo, opens a chat, and hits send. It is slow, prone to human error, and leaves your Odoo database completely blind to customer conversations.
Connecting the official WhatsApp Business API to Odoo fixes this. It puts message buttons directly inside Odoo Chatter, automates PDF sending for invoices and sales orders, and logs incoming replies against customer records.
Doing it wrong will get your phone number permanently banned by Meta or choke your Odoo database with pending cron jobs. Here is how to build this connection properly, what it costs, and where setups usually fail.
Three Ways to Link Odoo and WhatsApp API
You cannot simply drop a Python library into Odoo and start sending messages from your personal phone number. Meta requires you to go through the Cloud API or an On-Premises API gateway. How you link this to Odoo depends on your Odoo version and edition.
1. Native Odoo 17 Enterprise Module
If you run Odoo 17 Enterprise, WhatsApp integration comes out of the box. Odoo built a native module that connects directly to the Meta Cloud API. You configure your Meta App ID, Phone Number ID, and System User Access Token directly in Settings > Technical > WhatsApp Applications.
This is the cleanest route for Enterprise users. It native-links to Chatter, handles incoming webhooks out of the box, and supports interactive message templates.
2. OCA Modules or Custom Python Code (Odoo Community & Older Versions)
If you run Odoo Community Edition (v14, v15, v16, or v17) or older Enterprise versions, you do not have native WhatsApp settings. You have two options here: install an open-source module from the Odoo Community Association (OCA) or write a small custom module that hooks into Odoo models.
A custom module usually adds an action button on `account.move` (Invoices) or `sale.order` (Sales Orders). When clicked, Python's `requests` library sends a POST payload directly to Meta's Graph API endpoints.
3. Third-Party API Gateways
Connecting Odoo directly to Meta's Graph API requires managing long-lived access tokens, standardizing phone number formats, and setting up HTTPS endpoints for webhooks. If you want to bypass that administrative overhead, you can use a gateway service like WA Link.
We build HTTP API gateways that accept simple JSON payloads from Odoo and handle the Meta routing for you. However, a gateway will not bypass Meta's rules. You still need approved templates for business-initiated messages, and your phone numbers still need to be valid.
Never use unofficial WhatsApp Web wrappers, Selenium scripts, or headless browser automation with Odoo. Meta detects these automated browser sessions rapidly. Your number will be banned within days, often permanently.
How the Connection Architecture Works
A reliable connection relies on a two-way data flow between your Odoo server and Meta's servers.
| Direction | Trigger Event | Technical Mechanism | Data Transferred |
|---|---|---|---|
| Outgoing | Invoice posted or button clicked in Odoo | Odoo Python backend sends HTTPS POST request to API | Recipient number, Template ID, variable parameters, PDF media link |
| Incoming | Customer replies on WhatsApp | Meta sends HTTPS POST webhook to Odoo controller | Message body, sender number, timestamp, message delivery status (sent/delivered/read) |
For incoming webhooks to work, your Odoo instance must be accessible via public HTTPS. If your Odoo server sits behind a local firewall on a private LAN without an SSL certificate, Meta's webhooks will fail silently. You must set up a reverse proxy (like Nginx) with a valid SSL certificate or use a secure tunnel service during development.
Sending Payment Reminders: A Worked Example
Let us look at a real scenario: automatically sending an overdue invoice reminder with a PDF attachment when an invoice becomes 7 days late.
Step 1: Get the Message Template Approved
You cannot send free-form text to start a conversation on WhatsApp API. You must submit a template in the Meta Developer Portal or Meta Business Manager first.
Your template text might look like this:
"Hello {{1}}, your invoice {{2}} for {{3}} was due on {{4}}. Please find the payment copy attached. Reply to this message if you need assistance."
Specify the parameters clearly:
- `{{1}}`: Customer Contact Name
- `{{2}}`: Invoice Reference Number (`INV/2024/00102`)
- `{{3}}`: Amount Due (`PKR 45,000` or `INR 12,500`)
- `{{4}}`: Due Date (`2024-10-15`)
- Header: Document Attachment (PDF)
Meta usually approves utility templates within 5 to 30 minutes.
Step 2: The Logic Inside Odoo
In Odoo, an automated action (`base.automation`) or an `ir.cron` job runs daily to check for overdue invoices. The Python method collects the target invoices and formats the payload.
Here is what the bare JSON payload looks like when Odoo dispatches it to Meta's API:
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "923001234567",
"type": "template",
"template": {
"name": "invoice_payment_reminder",
"language": { "code": "en" },
"components": [
{
"type": "header",
"parameters": [
{
"type": "document",
"document": {
"link": "https://your-odoo-domain.com/web/content/account.move/102/invoice_pdf",
"filename": "Invoice_INV202400102.pdf"
}
}
],
"type": "body",
"parameters": [
{ "type": "text", "text": "Ali Khan" },
{ "type": "text", "text": "INV/2024/00102" },
{ "type": "text", "text": "PKR 45,000" },
{ "type": "text", "text": "2024-10-15" }
]
}
]
}
}
Understanding the Costs
WhatsApp API pricing depends on conversation categories (Utility, Authentication, Marketing, Service) and the country code of the customer's phone number. You are charged per 24-hour conversation window, not per individual message.
For example, if you send an invoice reminder (a Utility conversation) to 1,000 customers in Pakistan, Meta charges roughly $0.0080 per conversation window. Sending 1,000 reminders costs around $8.00 (approx. 2,200 PKR).
If you send those same 1,000 utility reminders to numbers in India, Meta's rate for Utility conversations is roughly $0.0042 per conversation (approx. ₹0.35 each, totaling ₹350).
Always verify the current exact country rates on Meta's official conversation pricing page, as exchange rates and regional fees update periodically.
What Breaks in Production (and How to Avoid It)
Setting this up on a local staging environment is easy. Keeping it running when your business processes hundreds of transactions a day requires avoiding a few distinct failure points.
1. Bad Phone Number Formatting
Meta requires international E.164 format without spaces, dashes, or leading zeroes. For example, `+92 300 1234567` or `03001234567` will fail. It must be converted to `923001234567` before hitting the API.
In Odoo, users type phone numbers however they want into `res.partner`. If you do not sanitize these strings programmatically before sending the API request, Meta returns a `(#100) Param recipient_type missing or invalid` or an undeliverable error code (`#131026`).
Write a simple Python helper method in Odoo to strip non-digit characters and prepend the default country code if missing:
import re
def sanitize_whatsapp_number(phone, default_country_code="92"):
if not phone:
return False
clean = re.sub(r'\D', '', phone)
if clean.startswith('0'):
clean = default_country_code + clean[1:]
return clean
2. The 24-Hour Messaging Window
When a customer messages your business on WhatsApp, a 24-hour customer service window opens. During this window, you can reply with standard, unapproved free-form messages from Odoo Chatter.
Once those 24 hours pass, Meta blocks free-form messages. If your sales agent tries to type a reply in Odoo Chatter on day two, Meta drops the message and returns error code `#131047` (*Re-engagement message*). You can only message that customer again by sending a pre-approved Template Message.
3. PDF Document URL Access
When attaching invoices, quote PDFs, or delivery orders to an API payload, Meta's servers must download the file from your Odoo server URL. If your Odoo system requires authentication to view attachment URLs, Meta will get a `403 Forbidden` error when trying to fetch the PDF.
You must ensure attachment links generated for WhatsApp outgoing queues are publicly accessible attachment tokens or served via an unauthenticated, secure controller endpoint.
4. Cron Job Backlogs
If you process 5,000 invoices at month-end and try to send all WhatsApp notifications synchronously inside the standard request thread, Odoo will time out. The web worker will die, leaving half your invoices posted and half missing.
Always route outgoing WhatsApp messages through Odoo's mail queue or an asynchronous queue background process (`queue_job` module in Community). Process sending in batches of 20 to 50 items per minute to avoid hitting Meta's rate limits.
Frequently Asked Questions
Can I connect WhatsApp API to Odoo Community Edition?
Yes. Odoo Community does not have native WhatsApp settings like Enterprise v17, but you can install third-party community modules or write a custom Python module. The backend API mechanisms (sending HTTPS requests to Meta or a gateway) work identically in Community and Enterprise.
What happens if Meta rejects my message template?
If Meta rejects a template, it is usually because the category was wrong (e.g., submitting a promotional offer as a "Utility" template), the parameters lacked context samples, or the text contained grammar errors. Edit the template in your Meta Business Manager, correct the issue, and resubmit it. Rejections do not harm your WhatsApp phone number health score.
Do I need a separate phone number for the WhatsApp API?
Yes. You cannot run the standard WhatsApp mobile app and the WhatsApp API on the same phone number simultaneously. To register a number with the API, you must delete the existing WhatsApp account associated with that SIM card first. Use a dedicated virtual or virtual-SIM business number for your Odoo integration.
Why are incoming customer replies not appearing in Odoo Chatter?
This usually happens because your Odoo server's webhook URL is misconfigured in Meta's Developer Portal, your SSL certificate is invalid, or your Nginx reverse proxy is blocking incoming POST requests to `/whatsapp/webhook/` (or your custom module route). Check your Odoo server access logs to see if Meta's requests are hitting the server with a `200 OK` status.
Can I send bulk marketing messages from Odoo via WhatsApp API?
You can send bulk promotional messages using Marketing templates, but you must be careful. If recipients mark your messages as spam, your number's quality rating drops. If it drops to "Low", Meta will restrict your daily sending limits (from 10,000 per day down to 1,000 or 250). Build an explicit opt-in filter in Odoo before sending mass marketing campaigns.
Your Next Step
Before writing Python code or installing third-party modules in Odoo, open the Meta Developer Portal and create a Meta App with the WhatsApp product added. Send a single test template message directly from Meta's dashboard to your personal phone number. Once that test payload succeeds and you have a valid System User Access Token and Phone Number ID, connecting it to Odoo takes less than an hour.