Skip to main content
Version: Latest

Event Types and Payload

When an event occurs, Hub Chatt2.me makes a POST to your endpoint with a JSON payload. This page describes the payload structure for each event type.

Message event

Fired when a user sends a message to one of your channels.

General payload fields

FieldTypeDescription
eventTypestringAlways Message
channelIdstringUUID of the channel that received the message (use as from when replying)
messageIdstringUnique ID of the received message
fromstringSender's identifier in the channel (use as to when replying)
timestampnumberUnix timestamp of when the message was sent by the user
channelstringChannel name: whatsapp, instagram, messenger, telegram, sms
contentobjectContent of the received message

Example — Text message received

{
"eventType": "Message",
"channelId": "6cbd6789-1d2b-47e0-9391-5eb91d2839ea",
"messageId": "abc123de-f456-789a-bcde-f01234567890",
"from": "5511993986082",
"timestamp": 1700000000,
"channel": "whatsapp",
"content": {
"type": "text",
"text": "Hello, I'd like to know more about your products"
}
}

Example — Interactive button reply

{
"eventType": "Message",
"channelId": "6cbd6789-1d2b-47e0-9391-5eb91d2839ea",
"messageId": "def456gh-1234-5678-abcd-901234567890",
"from": "5511993986082",
"channel": "whatsapp",
"content": {
"type": "interactive",
"interactive": {
"type": "button_reply",
"button_reply": {
"id": "SUPPORT",
"title": "Support"
}
}
}
}

Example — Shared location

{
"eventType": "Message",
"content": {
"type": "location",
"location": {
"latitude": -23.5505,
"longitude": -46.6333
}
}
}

MessageStatus event

Fired when the status of a message you sent is updated.

FieldTypeDescription
eventTypestringAlways MessageStatus
messageIdstringID of the message (returned when you sent it)
statusstringNew message status
timestampnumberUnix timestamp of the status event
channelstringChannel where the message was sent

Possible statuses

StatusDescription
sentSent to the channel server
deliveredDelivered to the recipient's device
readRead by the recipient (when available in the channel)
failedDelivery failed

Example — Message delivered

{
"eventType": "MessageStatus",
"messageId": "9307b9ab-5fab-4151-b7c2-b00c2a8a6e8e",
"status": "delivered",
"timestamp": 1700000060,
"channel": "whatsapp"
}

Example — Message read

{
"eventType": "MessageStatus",
"messageId": "9307b9ab-5fab-4151-b7c2-b00c2a8a6e8e",
"status": "read",
"timestamp": 1700000120,
"channel": "whatsapp"
}

Replying to the user from the webhook

When receiving a Message event, use the payload fields to build the reply:

Node.js — Auto-reply
app.post('/webhooks/chatt2me', async (req, res) => {
res.status(200).send('OK'); // Respond 200 first!

const { eventType, channelId, from, content } = req.body;

if (eventType === 'Message' && content?.text === 'hi') {
await fetch('https://api.chatt2.me/v1/communication/whatsapp/message', {
method: 'POST',
headers: {
'x-api-key': process.env.CHATT2ME_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
from: channelId, // UUID of the channel that received the message
to: from, // Identifier of the user who sent it
content: { text: 'Hello! How can I help you?' },
}),
});
}
});
Respond 200 before processing

Send 200 OK immediately upon receiving the webhook and process the logic afterwards (or in the background). This prevents timeouts and false errors in the webhook log.


Next steps