orvachat

Getting Started

How To Receive Messages and Media From orvachat

Get new WhatsApp messages on your webhook, read the text and sender, and download photos and files.

When someone sends a message to your number, orvachat sends it to your webhook right away as a POST request. This page shows what arrives, how to read the text and the sender, and how to get photos, voice notes and files.

1. Set your webhook

  1. Open the Developer API page and pick the number.
  2. Enter your webhook URL (https). Keep the Message event on.
  3. Copy the signing secret. You need it to check that each event really comes from us. See Webhook Setup and Signatures.

2. What arrives

The body is JSON with two parts: type (the event name) and event. For a message, event.Info says who sent it and where, and event.Message holds the content.

A text message
{
  "type": "Message",
  "event": {
    "Info": {
      "Chat": "[email protected]",
      "Sender": "[email protected]",
      "IsFromMe": false,
      "IsGroup": false,
      "AddressingMode": "pn",
      "SenderAlt": "70072425046185@lid",
      "ID": "3EB0ABCDEF1234567890",
      "Type": "text",
      "PushName": "Ali",
      "Timestamp": "2026-11-28T10:15:00+05:00"
    },
    "Message": {
      "conversation": "Hi, is this in stock?"
    },
    "IsEphemeral": false,
    "IsViewOnce": false
  }
}

Read the text

  • A plain message has the text in Message.conversation.
  • A reply, or a message with a link, has it in Message.extendedTextMessage.text.
  • Photos, videos and files can have a caption, for example Message.imageMessage.caption.

So check them in that order, and use the first one you find.

Who sent it, and where

  • Info.Chat is the chat: a person, or a group ending in @g.us. Send your reply to this.
  • Info.Sender is the person who wrote it. In a private chat it is the same person as the chat.
  • Info.IsGroup tells you if it came from a group. Info.IsFromMe is true for messages you sent from the phone. Skip those so you don't answer yourself.
  • Info.PushName is the name the person set in WhatsApp.

Important

Chat and Sender are not always phone numbers. WhatsApp can use a hidden id that ends in @lid instead. When that happens, Info.SenderAlt often holds the phone address (…@s.whatsapp.net). Info.AddressingMode says which one is used: pn (phone number) or lid.

You can always reply to the id you received. To find the hidden id for a phone number, use Get LID From Phone Number.

3. Photos, voice notes and files

A media message has an imageMessage, videoMessage, audioMessage (voice notes too), documentMessage or stickerMessage inside Message. It holds the details needed to download the file, not the file itself.

A photo in a group
{
  "type": "Message",
  "event": {
    "Info": {
      "Chat": "[email protected]",
      "Sender": "70072425046185@lid",
      "IsFromMe": false,
      "IsGroup": true,
      "AddressingMode": "lid",
      "SenderAlt": "[email protected]",
      "ID": "3EB0FEDCBA0987654321",
      "Type": "media",
      "MediaType": "image",
      "PushName": "Ali",
      "Timestamp": "2026-11-28T10:16:00+05:00"
    },
    "Message": {
      "imageMessage": {
        "URL": "https://mmg.whatsapp.net/o1/v/t62.7118-24/…",
        "mimetype": "image/jpeg",
        "caption": "This one please",
        "fileSHA256": "kXq…=",
        "fileLength": 48213,
        "mediaKey": "Zx9…=",
        "fileEncSHA256": "p0M…=",
        "directPath": "/o1/v/t62.7118-24/…"
      }
    }
  },
  "base64": "data:image/jpeg;base64,/9j/4AAQ…",
  "mimeType": "image/jpeg",
  "fileName": "3EB0FEDCBA0987654321.jpg"
}

Often the event also carries the file itself in base64, with mimeType and fileName. If it is there, use it. If not, download the file: send the fields from the media message to the download endpoint for its kind.

4. Full example (Node.js)

This server checks the signature, prints the text and sender, and downloads photos.

server.mjs
import express from "express";
import crypto from "node:crypto";

const API = "https://orvachat.com/api/v1";
const KEY = process.env.ORVACHAT_API_KEY;        // your API key
const SECRET = process.env.ORVACHAT_WEBHOOK_SECRET; // your signing secret

const app = express();

// Keep the raw body: the signature is made from the exact bytes.
app.post("/webhook", express.raw({ type: "application/json" }), async (req, res) => {
  const expected = "sha256=" + crypto.createHmac("sha256", SECRET).update(req.body).digest("hex");
  const got = Buffer.from(req.get("X-Webhook-Signature") ?? "");
  if (got.length !== expected.length || !crypto.timingSafeEqual(got, Buffer.from(expected))) {
    return res.sendStatus(401);
  }
  res.sendStatus(200); // answer fast, then do the work

  const { type, event } = JSON.parse(req.body);
  if (type !== "Message" || event.Info.IsFromMe) return;

  const m = event.Message ?? {};
  const text = m.conversation ?? m.extendedTextMessage?.text ?? m.imageMessage?.caption ?? "";
  const sender = event.Info.Sender;
  console.log(`${event.Info.PushName} (${sender}) wrote: ${text}`);

  if (m.imageMessage) {
    const img = m.imageMessage;
    const r = await fetch(`${API}/chat/downloadimage`, {
      method: "POST",
      headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
      body: JSON.stringify({
        Url: img.URL,
        DirectPath: img.directPath,
        MediaKey: img.mediaKey,
        Mimetype: img.mimetype,
        FileEncSHA256: img.fileEncSHA256,
        FileSHA256: img.fileSHA256,
        FileLength: img.fileLength,
      }),
    });
    const { data } = await r.json();
    // data.Data is "data:image/jpeg;base64,..."
  }
});

app.listen(3000);

Good to know

  • Answer with a 2xx status within 10 seconds. Do slow work after you answer.
  • We may send the same event again if your server did not answer in time. Use Info.ID to skip messages you already handled.
  • See every field of the event on Webhook: Message Received.