Any Message

Catch-all event for any message activity in the session.

Best practices

  • Use this for logging or backup systems that need to track every single movement.

  • Consider filtering specific events instead if you only need certain message types.

The Omniscient Listener: Mastering the "Message Any" Webhook

In the architecture of a mission-critical communication platform, data gaps are unacceptable. While specific webhooks like [message.received] or [message.revoked] provide targeted signals, the Message Any event is the global catch-all—the "Omniscient Listener" of the Wawp platform. It fires for every single message-related movement within a session, including incoming messages from customers, outgoing messages sent by the API, manual responses made on a physical phone, and even ephemeral system messages.

This guide provides an architectural deep-dive into the strategic value of global ingestion, moving beyond "Simple Logging" into the realm of Total Auditability, Data Lake Hydration, and Operational Traceability.


🏗️ Architectural Philosophy: The Stream of Consciousness

To master the Message Any API, one must first recognize the shift from "Event Filtering" to "Event Aggregation." This webhook represents the raw, unfiltered pulse of the WhatsApp session.

1. The Full-Spectrum View

The [message.any] event collapses the distinction between source and destination.

  • The Bidirectional Stream: It captures both his (@c.us/Incoming) and yours (fromMe: true/Outgoing). This provides a singular sequence of events, which is essential for reconstructing the "Conversational Timeline" in a linear format.
  • The Identity Mosaic: By capturing interactions from Individuals (@c.us), Groups (@g.us), and Newsletters (@newsletter), it creates a holistic view of the instance's total cognitive load and engagement volume.

2. The Relationship with Specific Webhooks

It is important to understand that [message.any] is Redundant by Design. Every event it captures is likely also emitted by a more specialized webhook. Its value lies not in what it captures, but in its Consolidated Nature. A high-performance architecture often uses specialized webhooks for "Business Logic" (e.g., triggering a bot response) and [message.any] for "Compliance and Archiving" (e.g., long-term storage in a Data Lake).


🚀 Strategic Use Cases: Powering the Auditable Business

The "Message Any" webhook is the engine of technical accountability and historical truth.

1. High-Fidelity Audit Trails for Compliance

In industries such as Finance, Insurance, and Healthcare, every interaction must be logged for legal review. The Strategic Workflow: Point your [message.any] stream directly at an immutable storage solution (like Amazon S3 or a specialized Audit DB). Because this webhook captures manual phone messages as well as API messages, it provides a "Complete Truth" that cannot be bypassed by an agent picking up a physical phone. This ensures your organization remains compliant with non-repudiation and transparency mandates.

2. Data Lake Hydration for AI and Analytics

To train a custom LLM or to generate "Sentiment Trends," you need the largest possible dataset. The Data Pipeline: Use [message.any] to hydrate your Data Lake. By analyzing the total stream, you can identify "Peak Activity Hours," "Common Conflict Keywords," and "Customer Effort Scores" across the entire session. This moves your organization from "Reactive Support" to Proactive Operations, where business decisions are based on the aggregate signal of every interaction.

3. The "State Reconstruction" Pattern

If your primary database suffers a catastrophic failure, how do you rebuild the conversational state of 10,000 active chats? The Recovery Strategy: If you have a complete log of [message.any] events, you can "Replay" the logs to reconstruct the exact state of every chat, including the last message sent, the last reaction, and the last update. This provides a "High-Availability Safety Net" that protects your business from data loss in its primary ingestion layers.


🛡️ Administrative Mandate: Balancing Volume and Value

Scaling a "Global Listener" requires professional-grade infrastructure.

1. Engineering for High-Throughput

A single Wawp instance can generate thousands of events per hour. If you have 100 instances, the [message.any] stream becomes a "Firehose." The Technical Standard: Do not attempt to process [message.any] synchronously within your web server. Instead, use a Message Broker (like RabbitMQ or Kafka). Let your webhook handler do one thing: push the raw payload into the queue and return a 200 OK instantly. Your "Archiver Workers" can then drain the queue at their own pace, ensuring your server never buckles under peak traffic.

2. The "Signal-to-Noise" Decision

Not every event in the "Any" stream is valuable for your CRM. The Strategic Filter: Implement a "Classification Layer." Store everything in your raw logs for compliance, but only "Promote" specific events from the [message.any] stream to your active UI if they meet certain criteria. This prevents your agent dashboard from being cluttered with redundant system messages while still maintaining the integrity of the underlying audit trail.


🛡️ Operational Best Practices: Optimizing the Global View

  • De-duplication Logic: Since [message.any] captures events also sent by other webhooks, ensure your database uses the Message ID as a unique constraint. This prevents "Double Counting" messages in your analytics.
  • The "Shadow User" Pattern: Monitor the [fromMe: true] messages to track agent productivity. Since this captures manual phone replies, you can see if an agent is bypassing your official CRM to talk to customers directly. This is a vital tool for quality assurance and "Shadow IT" prevention.
  • Metadata Enrichment: The [message.any] payload provides basic fields, but can be enriched by cross-referencing with your Contacts Database. A premium architecture resolves the JIDs into "Known Names" before archiving the event, making the audit logs human-readable.

⚙️ Engineering Best Practices: The Validation Loop

  1. Idempotent Ingestion: Always use the Message ID and the Event Type as a combined key. If you receive the same ID via message.received and message.any, your logic should treat the second arrival as a "No-Op."
  2. Verify Payload Integrity: Ensure you are using the [engine] field to handle any subtle differences in payload structure between different Wawp engines (e.g., WEBJS vs. MD).
  3. Scoped Resource Allocation: Dedicate separate compute resources or database instances for your "Global Ingestion" pipeline. You don't want a sudden spike in message traffic to slow down your primary "Reply Logic" workers.

🎯 Conclusion: The Single Source of Truth

The Message Any Webhook is the "Black Box Recorder" of your digital brand. By building an architecture that embraces the firehose of data, you move your organization from "Partial Visibility" to Complete Insight. You build systems that never forget, never miss a signal, and always maintain a high-fidelity record of every word, reaction, and movement. In the world of Wawp, "Any" is the signal that ensures your business is always built on the foundation of total, auditable truth.

Expected Responses

Explore all possible responses and outcomes from the server. We have documented each status code with data examples to make success and error handling easier.

Webhook Payload Example
application/json
string *
number *
string *
object *
string *
string *
object *
object *

Example

{
"id": "evt_01...",
"timestamp": 1634567890123,
"session": "default",
"metadata": {
  "user.id": "123",
  "user.email": "email@example.com"
  },
"engine": "WEBJS",
"event": "message.any",
"payload": {
  "id": "true_11111111111@c.us_...",
  "body": "Catching everything!",
  "from": "11111111111@c.us",
  "to": "22222222222@c.us"
  },
"me": {
  "id": "11111111111@c.us",
  "lid": "123@lid",
  "pushName": "Instance"
  }
}

Command Palette

Search for a command to run...