waha icon indicating copy to clipboard operation
waha copied to clipboard

[Feature Request][ALL] - Consistent API Responses for sendText (and other API) - WAMessage Object as response of sendText

Open francescolovecchio opened this issue 1 year ago • 3 comments

Describe the bug

When I send a message to /api/sendText I expect a WAMessage as response but I find:

{
  "key": {
    "remoteJid": "[email protected]",
    "fromMe": true,
    "id": "3EB08A6895830F110A5E4D"
  },
  "message": {
    "extendedTextMessage": {
      "text": "Hi there!"
    }
  },
  "messageTimestamp": "1738070128",
  "status": "PENDING"
}

Version

{
  "version": "2025.1.6",
  "engine": "NOWEB",
  "tier": "PLUS",
  "browser": "/usr/bin/chromium"
}

Steps

To Reproduce Steps to reproduce the behavior:

Send /api/sendText and check the response.

Expected behavior

I expect to receive a WAMessage as response when sending a message. If not expected, from the docs I didn't find any reference.

patron:PLUS

francescolovecchio avatar Jan 28 '25 13:01 francescolovecchio

Hi! Yes, right now it's a bit different response (it returns pure _data field from message event, basiclly) We kept it for now for backward compatability, all engines send their own format in "sendSomething" apis.

We'll add a new API for that in the future, had this in our roadmap for years... 👍

patron:PRO

devlikepro avatar Jan 29 '25 00:01 devlikepro

Hi, thank you! Do you have an idea about the possible release date (less or more)?

If it is more than 1 month, could you share the schema of the response for NOWEB engine and share how the message id in the new format is build?

patron:PLUS

francescolovecchio avatar Jan 29 '25 07:01 francescolovecchio

more than 1 month :(

There's no actual schema. You can combine key to get the id as following

{key.fromMe}_{key.remoteJid}_{key.id}

there' 4 parts for groups also, something like

{key.fromMe}_{key.remoteJid}_{key.id}_{key.participant}

You can listen to message.any event and when you send a message via sendText - compare it with message.any payload to find the right mapping

or in source code https://github.com/devlikeapro/waha/blob/core/src/core/engines/noweb/session.noweb.core.ts#L1667-L1694

patron:PRO

devlikepro avatar Jan 29 '25 09:01 devlikepro