### Inbound Message Posting API Source: https://github.com/beacon21m/adaptor_whatsapp/blob/main/README.md Receives WhatsApp messages and POSTs them to the Gateway API. ```APIDOC ## POST /api/messages ### Description This endpoint receives inbound messages from WhatsApp and forwards them to the Beacon Gateway API. ### Method POST ### Endpoint `${GATEWAY_API_BASE_URL}:${PORT}/api/messages` ### Parameters #### Request Body - **networkId** (string) - Required - The ID of the network (e.g., 'whatsapp'). - **botId** (string) - Required - The ID of the bot. - **botType** (string) - Required - The type of the bot (e.g., 'brain'). - **groupId** (string) - Optional - The WhatsApp group JID if the message is from a group. - **userId** (string) - Optional - The WhatsApp user JID if the message is a direct message or the author in a group. - **messageId** (string) - Optional - The provider message ID. - **message** (string) - Required - The text content of the message. ### Request Example ```json { "networkId": "whatsapp", "botId": "wa183", "botType": "brain", "groupId": "xxxx@g.us", "userId": "xxxx@c.us", "messageId": "true_xxxx@g.us~_0~0~1~0|0=1678886400000", "message": "Hello from WhatsApp!" } ``` ### Response #### Success Response (200 or 204) Indicates the message was successfully received and processed by the adaptor. #### Response Example (No specific response body is detailed, typically an empty success response or a status code). ``` -------------------------------- ### Outbound Message Subscription API Source: https://github.com/beacon21m/adaptor_whatsapp/blob/main/README.md Subscribes to Server-Sent Events (SSE) from the Gateway API to send messages to WhatsApp. ```APIDOC ## SSE /api/messages/out/:networkId/:botId ### Description This endpoint is an SSE stream that the adaptor subscribes to. Messages received on this stream are sent to WhatsApp. ### Method GET (SSE) ### Endpoint `${GATEWAY_API_BASE_URL}:${PORT}/api/messages/out/${NETWORK_ID}/${BOT_ID}` ### Parameters (No direct parameters for the GET request, but the URL includes path parameters) - **networkId** (string) - Path parameter: The ID of the network. - **botId** (string) - Path parameter: The ID of the bot. ### SSE Event Data (JSON Payload) - **networkId** (string) - The ID of the network. - **botId** (string) - The ID of the bot. - **botType** (string) - The type of the bot. - **groupId** (string) - Optional - Target group JID for the message. - **userId** (string) - Optional - Target user JID for the message. - **replyMessageId** (string) - Optional - The message ID to reply to (quoted message). - **message** (string) - Required - The text content to send. - **direction** (string) - Optional - If present and not equal to 'out', the adaptor will skip sending this message to prevent echoing. ### Request Example (SSE Data) ```json { "networkId": "whatsapp", "botId": "wa183", "botType": "brain", "userId": "xxxx@c.us", "message": "This is a reply.", "replyMessageId": "true_xxxx@c.us~_0~0~1~0|0=1678886400000" } ``` ### Response #### Success Response (200 OK with SSE Stream) The connection is kept open, and message data is sent over the SSE stream. #### Response Example (SSE) ``` id: 1 data: {"networkId":"whatsapp","botId":"wa183","botType":"brain","userId":"xxxx@c.us","message":"This is a reply.","replyMessageId":"true_xxxx@c.us~_0~0~1~0|0=1678886400000"} ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.