How to add WhatsApp to TOTVS Protheus
Short answer
Protheus has no WhatsApp channel built in, so you put a small middleware between the WhatsApp Business Platform (Cloud API or a BSP) and Protheus REST services or ExecAuto routines. Outbound messages are triggered from Protheus events or scheduled queries; inbound replies are parsed and written back through controlled routines, with approval where money is involved.
Most Protheus shops already live on WhatsApp. Buyers confirm delivery dates with suppliers there, sales reps send quotes there, and the plant manager asks for the status of an order there. The ERP never sees any of it, so the answer lives in someone's phone and the Protheus order (SC7 or SC6) stays stale.
The goal is not a chatbot for its own sake. It is to push the few events that matter out to WhatsApp, and to let a short reply from a supplier or approver land in the right Protheus record without anyone retyping it.
Protheus runs on AdvPL/TL++ with an AppServer, DBAccess and a relational database underneath, often on-premises in Brazil, Latin America and parts of Asia. That shapes the design: the middleware has to reach the AppServer inside the network, and the WhatsApp side has to reach out through a public webhook without exposing the ERP.
What teams use it for
Supplier delivery confirmation on purchase orders
When a purchase order (SC7) is approved, send the supplier a template with the item list and promised date. A reply of CONFIRMA or a new date updates the delivery date field through a controlled routine instead of a buyer typing it.
Order status for sales reps and customers
A rep sends a sales order number and gets back status, billing state and invoice number from SC5/SC6 and SF2. Customers get the same through a template tied to their registered number on SA1.
Shipment and NF-e notices
After a Nota Fiscal Eletronica is authorised, send the DANFE link and tracking details to the customer contact, driven by the invoice event rather than a manual email.
Approval nudges for managers
Purchase request and order approvals sit in the document approval flow. A WhatsApp message with a deep link or an APROVAR/REJEITAR reply shortens the wait that mobile-less managers create.
Overdue receivables reminders
Titles in SE1 past due generate a polite reminder to the finance contact, with a payment link, and the reply is logged against the customer record for the collections team.
TOTVS Protheus integration surface
- Protheus REST services published by the AppServer HTTPREST section, including TOTVS standard APIs and custom endpoints written in TL++ with the FWRest or WsRestFul classes (exact class names depend on the release).
- ExecAuto routines such as MATA120 (purchase orders) and MATA410 (sales orders), which apply Protheus business rules when you write back instead of inserting into tables.
- Pontos de Entrada (user exits) on order and invoice routines, usable as event hooks to enqueue a notification record in a custom table.
- Direct read access to the database through DBAccess targets (SQL Server, Oracle or PostgreSQL by installation) for status lookups, with the D_E_L_E_T_ flag and RECNO handled correctly.
- Scheduled jobs through the Protheus scheduler or a standalone TL++ job for polling pending notifications when event hooks are not acceptable.
How it works
- 1
Register the WhatsApp sender and templates
Create a WhatsApp Business account with the Cloud API or a BSP, verify the business, and submit message templates in Portuguese and any other languages. Utility templates for order and delivery notices usually clear faster than marketing ones.
- 2
Build a notification queue inside Protheus
Create a small custom table (for example a Z-prefixed alias) holding event type, document key, recipient number and status. A user exit on order approval or invoice authorisation inserts a row; nothing is sent from inside the transaction.
- 3
Run a middleware service next to the AppServer
A small service reads the queue through a REST endpoint, resolves recipient numbers from SA1, SA2 or contact tables, fills the template and calls the WhatsApp API. It marks the row sent or failed so retries are safe.
- 4
Expose a webhook for inbound replies
WhatsApp posts replies to a public HTTPS endpoint. The service validates the signature, matches the sender to an open conversation, and classifies the message as a confirmation, a date change or free text.
- 5
Write back through ExecAuto or a custom routine
Confirmed dates and approvals go through a routine that applies the normal validations. Anything ambiguous goes to a buyer's worklist instead of changing data.
- 6
Log every message against the document
Store message id, text and outcome next to the order or invoice key so audit and support can see what the supplier actually said.
Example flows
Purchase order confirmation loop
Trigger: A purchase order is approved and released to the supplier.
- User exit inserts a queue row with the SC7 document and supplier contact.
- Middleware sends the template with item, quantity and requested date.
- Supplier replies with a new date in free text.
- Service extracts the date, shows it to the buyer for a one-click accept.
- On accept, the delivery date is updated through the standard routine.
Result: The order date reflects what the supplier said, with the message trail attached, and the buyer touched it once.
Customer order status lookup
Trigger: A registered customer contact sends an order number.
- Webhook matches the sender number to a customer and checks permission to see that order.
- Service queries order, billing and invoice status through a read-only endpoint.
- A short reply states stage, expected ship date and invoice number if issued.
Result: Fewer status calls to the sales desk, and answers that come from live Protheus data rather than from memory.
Keeping data on-prem
Keep the AppServer and database inside the network and let only the middleware face the internet. The middleware can sit in a DMZ, call Protheus REST over an internal firewall rule, and receive the WhatsApp webhook through a reverse proxy. Message content is the part that leaves your environment, so send only what the recipient needs: document number, dates and quantities, not prices or margins. If free-text replies need language understanding, that step can run on an open-weight model hosted on your own GPUs, so supplier messages are never sent to a third-party model. The WhatsApp transport itself still goes through Meta or the BSP, which is unavoidable for the channel.
Security checklist
- Verify the webhook signature and reject any request that does not match; never trust the sender number alone for actions that change data.
- Use a dedicated Protheus user for the integration with rights limited to the routines it needs, so ERP roles still bound what it can do.
- Require explicit opt-in and keep the consent record per contact, as the platform and Brazilian LGPD both expect.
- Mask or omit commercial values in templates and store messages with the same retention rules as other business correspondence.
Ways to get it done
Off-the-shelf WhatsApp connector from a Protheus partner or BSP
Effort: Days to a few weeks, plus template approval time.
Good for one-way notices such as invoices and order status where standard events are enough.
Build the middleware in-house with the TL++ team
Effort: Several weeks for a first two-way flow, ongoing template upkeep.
Fits teams that already maintain custom REST services and want full control of data and routines.
Work with a partner such as Netray
Effort: A scoped pilot on one flow, then extension flow by flow.
Useful when replies must be understood, validated and routed with approval, and when language models must stay on-prem.
Pitfalls
- !Sending from inside the order transaction, so a slow WhatsApp call blocks a buyer's save. Always queue.
- !Matching supplier contacts by phone number stored in free-text fields; clean the numbers and use international format first.
- !Letting a free-text reply write directly to a date or quantity field without a human accept step.
- !Forgetting the 24 hour customer service window: outside it only approved templates can be sent.
Frequently asked questions
Does TOTVS Protheus have a native WhatsApp integration?
Not as a standard module in the versions most plants run. Some partners and TOTVS offerings add messaging, but the common route is custom or partner middleware calling Protheus REST and ExecAuto. Check your release and any TOTVS cloud services you already license before building.
Can replies from WhatsApp update Protheus orders automatically?
Yes, through ExecAuto or a custom routine so the normal validations run. For purchase dates and approvals we recommend a human accept step first, then automate only the high-confidence replies once you have seen real traffic.
Which WhatsApp API should I use with Protheus?
The WhatsApp Business Platform Cloud API directly, or a BSP if you need local support and billing. Either way you need approved templates for business-initiated messages. The choice does not change the Protheus side much.
Can this run if Protheus is fully on-premises?
Yes. The AppServer stays internal and a middleware in a DMZ talks to both sides. Only the message payloads leave the network, and you control what they contain.
How do I stop sensitive data going into messages?
Define the template fields up front and exclude prices, margins and bank details. Fetch the full detail only when an authenticated user opens a link into Protheus or Fluig.
Want WhatsApp working on your TOTVS Protheus?
A free 30 minute assessment: we map the integration path for your version and setup, and where it should run.
Get a free assessment