Message Edited

Triggered when a sent message is modified by the user.

Best practices

  • Update the text content for the existing message ID in your database.

  • Consider keeping an edit history if your application requires message auditing.

The Second Chance: Mastering Message Edited Webhooks

In the fluid world of real-time communication, mistakes are inevitable. A typo, an incorrect price quote, or a misunderstood instruction can lead to significant business friction. The Message Edited feature on WhatsApp allows users and bots to correct their errors after the signal has been sent. Within the Wawp platform, the [message.edited] webhook is the definitive "Truth Update" signal, providing your infrastructure with the immediate notification that an existing interaction has been refined.

Handling edits is not just a technical requirement for UI synchronization; it is a fundamental pillar of Contextual Accuracy and Data Integrity. This guide provides an architectural deep-dive into the strategic management of edited content, moving beyond "Simple Text Updates" into the realm of Conversational Governance and Professional Auditing.


🏗️ Architectural Philosophy: The Mutable Message

To master the Message Edited API, one must first recognize the transition from "Immutable Logs" to "Living Conversations." A message is no longer a static data point; it is a dynamic entity that can be re-defined within a specific professional window.

1. The ID Linkage Strategy

The [message.edited] payload is structurally tied to the Original Message ID.

  • The Identifier Map: Your system must use the [id] in the payload to locate the specific record in your CRM or support database. Unlike a new message search, this is a "Correction Search."
  • The Body Delta: The payload provides the [newBody] (the current truth) and, where available, the [prevBody] (the historical context).

2. Contextual Reach (JIDs)

Edits occur across the entire spectrum of WhatsApp interaction:

  • Individual Chats (@c.us): Messages where [from] ends in @c.us represent personal or business-to-customer corrections.
  • Group Chats (@g.us): In a group environment, an edit by a specific participant updates the shared record for all members. Your ingestion layer must handle this as a "Group State Update," ensuring every agent looking at that group sees the corrected information simultaneously.

🚀 Strategic Use Cases: Powering Accurate Interactions

The message edited webhook ensures your internal systems remain in perfect harmony with the customer's intended meaning.

1. Zero-Friction Correction in Sales and Quoting

Imagine a sales agent sends a quote: "The total price is $1,500." They immediately realize it should be $1,050 and use the WhatsApp "Edit" feature to fix it. The Strategic Workflow: As soon as the [message.edited] webhook fires, your backend updates the Quote record in your CRM. If your system was about to generate an automated invoice based on the $1,500 text, the webhook serves as an Emergency Correction Trigger, ensuring the final document matches the user's intended price. This prevents billing errors and preserves customer trust.

2. Maintaining the "Contextual Truth" for Human Agents

There is nothing more confusing for a human support agent than a customer saying "As I said in the corrected message above..." if the agent's dashboard still shows the old, incorrect text. The Real-Time Sync: Use the edited webhook to trigger a WebSocket push to the agent's browser. The text should visually "Morph" or update with an "Edited" badge in real-time. This ensures the human agent is always looking at the Current State of the Truth, eliminating the "Responsiveness Gap" caused by outdated message logs.

3. AI Intent Re-Analysis

If your bot logic uses an LLM to determine customer intent, an edit is a "Signal of Refinement." The Logic: When a message is edited, your system should re-run its intent analysis on the [newBody]. If the original message was "How do I cancel?" but the user edited it to "How do I cancel my Gold plan specifically?", the refined intent allows your bot to provide a much more accurate, high-value response. An enterprise-grade system treats an edit as a Contextual Re-Trigger for its intelligent processing layers.


🛡️ Administrative Mandate: Scaling the Correction Pipeline

1. The Audit Trail Discipline

In regulated industries (like Legal, Finance, or Healthcare), you cannot simply overwrite data. You must maintain an "Edit History". The Strategic Architecture: When a [message.edited] event arrives, do not delete the old text. Instead, move the old text into a message_versions table. This provides a "Transparent History" of the interaction. If a dispute arises later, your compliance team can see exactly what was said first and how it was corrected. This is the gold standard for Technical Accountability.

2. Handling the "Race Condition" on Ingestion

In high-frequency environments, a user might send a message and edit it within 2 seconds. Because webhooks are asynchronous, your server might receive the [edited] event before the original [message] event is fully written to your primary database. The Robust Solution: Implement a "Staged Update". If your lookup for the original Message ID fails, place the edit payload into a "Pending Sync" queue for 5-10 seconds. Once the original message is ingested, the queue processor can then apply the edit. This ensures no correction is lost due to transient networking timing.


🛡️ Operational Best Practices: Designing for Professional Clarity

  • The "Edited" Badge UI: Always display a visual indicator (like a small clock icon or the word "Edited") next to the corrected text in your custom dashboard. This tells the agent: "The user changed their mind about what they said here."
  • MIME-Type Stability: Note that WhatsApp currently primarily supports editing Text Messages. If you receive an edit event for a media message (image/video), it typically signifies a change to the Caption. Your system should specifically target the caption field in your media records to apply these updates.
  • Coordinate with Acknowledgements (ACKs): Edits do not reset the delivery status. If a message was already "Read" (ACK 3), editing it doesn't turn the ticks back to gray. However, the corrected content should be treated as "Not yet consumed" by the agent until they look at the screen again.

⚙️ Engineering Best Practices: The Validation Loop

  1. Deduplicate Edits: If a user edits the same message three times in a row, you will receive three webhooks. Ensure your database update logic is idempotent and only processes the latest timestamp provided in the event metadata.
  2. Verify Edit Authority: In groups (@g.us), only the person who sent the message can edit it. Your system should verify the [author] in the edit payload matches the author of the original message to prevent state-injection errors.
  3. Cross-Instance Siloing: Ensure that the edit lookup is strictly scoped to the [session]. An edit for a message on Instance A should never attempt to update a message record belonging to Instance B.

🎯 Conclusion: Beyond Correction—The Art of the Living Record

The Message Edited Webhook is the "Living Update" of your digital brand. By building an architecture that listens, archives, and synchronizes these corrections, you move your organization from "Static Log Management" to Dynamic Conversational Alignment. You build systems that understand the fluidity of human intent, preserve the history of change, and always present the most accurate version of the truth. In the world of Wawp, an edit is not a failure; it is a vital conversational signal that ensures your integration remains as precise, as professional, and as adaptable as the business it represents.

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.edited",
"payload": {
  "id": "false_11111111111@c.us_...",
  "newBody": "Updated message text!",
  "prevBody": "Old message text"
  },
"me": {
  "id": "11111111111@c.us",
  "lid": "123@lid",
  "pushName": "Instance"
  }
}

Command Palette

Search for a command to run...