How to programmatically enable/disable or restart Meta AI Agent replies per thread using Baileys? #2651
|
Hi everyone, I am trying to programmatically toggle or restart the Meta AI Business Agent (also known as Meta AI Business Assistant / MAIBA) for specific chat threads on a WhatsApp Business account. Our goal is to pause the AI replies when a human agent takes over the chat (human takeover), and then re-enable/reactivate the AI replies when the human agent is finished (equivalent to the WhatsApp Web context menu feature "Restart AI replies"). I have inspected the Protobuf definitions in
What we have triedWe tried using await sock.appPatch({
syncAction: {
maibaAiFeaturesControlAction: {
aiFeatureStatus: 0 // ENABLED = 0 (or 1 for DISABLED)
},
timestamp: Date.now()
},
index: ['maiba_ai_features_control', targetJid], // We also tried global: ['maiba_ai_features_control']
type: 'regular',
apiVersion: 1,
operation: 0 // SET
});Result: The Our Current GraphQL Fallback (that works)Currently, we have to fall back to an HTTP request mimicking WhatsApp Web's graph query: POST https://graph.facebook.com/graphql
Doc ID: 27506359585667043
Variables: { consumer_lid: "...", phone_number: "...", thread_status: 'ENABLED' }While this HTTP approach works, it requires extracting an ephemeral, short-lived Questions:
Any guidance, example code, or insights on how to reverse-engineer this sync action would be highly appreciated! |
Replies: 1 comment 1 reply
|
I would separate two things here: Baileys knowing the protobuf shape, and WhatsApp accepting that change as an authoritative server-side control. The fields you found are real in
The fact that your WebSocket patch is accepted without error but the physical Business device state does not change is a strong signal that this is not the complete control path, or that the server treats it as a non-authoritative replicated patch. Your GraphQL fallback is probably closer to the actual product operation because it is the endpoint WhatsApp Web uses for the Business AI feature. I would not replace that with Baileys until someone captures the exact WhatsApp Web operation and maps it to a Baileys-supported send path. For reverse-engineering, I would test in this order:
So the short answer is: I do not think If this distinction matches what you are seeing, please mark the answer so others do not spend time on a protobuf-only patch that the server ignores. |
I would separate two things here: Baileys knowing the protobuf shape, and WhatsApp accepting that change as an authoritative server-side control.
The fields you found are real in
WAProto.proto, but that only means Baileys can encode/decode that part of app state. It does not necessarily mean a client can toggle MAIBA by sending an arbitraryappPatch. In particular:maibaAiThreadEnabledonConversationlooks like replicated conversation state. Updating the local app-state copy is not the same as asking WhatsApp's server to restart AI replies.maibaAiFeaturesControlActionis present as a sync action value, but the correct app-state collection, index tuple, version/MAC handling, and server-…