> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zavu.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quoted Replies

> Reply to a specific WhatsApp message so it appears quoted above your answer. Set content.replyToMessageId to the ID of the message you are answering.

A quoted reply shows the message you are answering above your own, the way a person does it in WhatsApp with a swipe. Use it when a conversation has several open questions and the contact needs to see which one you are answering.

## Send a Quoted Reply

Set `content.replyToMessageId` to the Zavu ID of the message you are answering. For a message the contact sent you, that is the `data.messageId` of its `message.inbound` webhook.

```typescript TypeScript theme={null}
const result = await zavu.messages.send({
  to: "+14155551234",
  channel: "whatsapp",
  text: "Your order ships tomorrow.",
  content: {
    replyToMessageId: "msg_abc123",
  },
});
```

```python Python theme={null}
result = zavu.messages.send(
    to="+14155551234",
    channel="whatsapp",
    text="Your order ships tomorrow.",
    content={"replyToMessageId": "msg_abc123"},
)
```

```bash cURL theme={null}
curl -X POST https://api.zavu.dev/v1/messages \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+14155551234",
    "channel": "whatsapp",
    "text": "Your order ships tomorrow.",
    "content": { "replyToMessageId": "msg_abc123" }
  }'
```

The quote works on every WhatsApp message type except `reaction`, which already names the message it reacts to. An image, a document or a button message can quote too: add `replyToMessageId` next to the rest of its `content`.

You can quote messages in both directions: one the contact sent you, or one you sent them. Either way it must belong to the conversation you are sending to, and the sender you send from must be the one that sent or received it.

## Replying from a Webhook

```typescript TypeScript theme={null}
app.post("/webhooks/zavu", async (req, res) => {
  const event = req.body;
  if (event.type === "message.inbound" && event.data.channel === "whatsapp") {
    await zavu.messages.send({
      to: event.data.from,
      channel: "whatsapp",
      text: await answer(event.data.text),
      content: { replyToMessageId: event.data.messageId },
      // Answer from the sender that received the message.
      "Zavu-Sender": event.senderId,
    });
  }
  res.sendStatus(200);
});
```

## What Comes Back

The stored message carries the full reply context, so `GET /v1/messages/{messageId}` shows what was quoted:

```json theme={null}
{
  "content": {
    "replyToMessageId": "msg_abc123",
    "replyToProviderMessageId": "wamid.HBgL...ORIGINAL",
    "replyToFrom": "+14155551234",
    "replyToText": "When does my order ship?",
    "replyToMessageType": "text"
  }
}
```

Only `replyToMessageId` is read from your request. The other `replyTo*` fields are filled in by Zavu.

## Errors

A quote that cannot be delivered as a quote is refused. Zavu never sends it unquoted.

| Status | Cause | Fix |
| - | - | - |
| `404` | The message is not in this project, or the ID is malformed | Use the `messageId` from the webhook or from `GET /v1/messages` |
| `400` | The send is not going out on WhatsApp or Telegram | Set `channel` explicitly. With `auto`, a phone number can route to SMS |
| `400` | The quoted message went out on another channel | Send on the channel of the quoted message |
| `400` | The quoted message belongs to another conversation than `to` | Quote a message exchanged with this recipient |
| `400` | The quoted message was sent or received by another sender | Pass that sender in the `Zavu-Sender` header |
| `400` | The quoted message failed | Quote a message that was delivered or received |
| `400` | The quoted message has no provider ID yet, because it is still queued | Wait until it is sent |
| `400` | `messageType` is `reaction` | Remove `replyToMessageId` |

Quoted replies also work on [Telegram](https://docs.zavu.dev/guides/telegram/overview.md#quoted-replies).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.