Skip to main content

Chat

Introduction to Webhook Events

This section details the webhook events available in the Chat system. Webhooks are used to notify your application about events that happen in conversations, such as creating, updating or deleting chats, and presence updates. Each event contains specific information, allowing your application to respond appropriately.

Events

chats.set

Structure

This event is fired when a list of all loaded chats is sent. It provides a snapshot of existing chats.
{
"event": "contacts.upsert", // Event name
"instance": { // Chat instance details
"owner": "[email protected]", // Chat owner
"name": "codechat", // Chat instance name
"id": "d4a58666-9737-485d-988b-d18a43ce8c75" // Unique identifier of the instance
},
"data": [ // List of chats
{
"participant": [], // Chat participants
"id": "[email protected]" // Chat identifier
}
]
}

chats.update

Structure

This event notifies you when there is an update to a chat, such as changes to messages or the unread message count.
{
"event": "chats.update", // Event name
"instance": { // Chat instance details
"owner": "[email protected]",
"name": "codechat",
"id": "d4a58666-9737-485d-988b-d18a43ce8c75"
},
"date": [
{
"id": "[email protected]", // Chat identifier
"conversationTimestamp": 1666473399, // Timestamp of last conversation
"unreadCount": 1 // Count of unread messages
}
]
}

chats.delete

Structure

This event informs you when a chat is deleted. It is useful for keeping the chat state in sync with your system.
{
"event": "chats.delete", // Event name
"date": [
"[email protected]" // Deleted chat identifier
],
"instance": { // Chat instance details
"owner": "[email protected]",
"name": "codechat",
"id": "d4a58666-9737-485d-988b-d18a43ce8c75"
}
}

presence.update

Structure

This event informs about the action the user is taking in the chat, such as writing or recording a message.
{
"event": "presence.update", // Event name
"date": {
"jid": "[email protected]", // User identifier in the chat
"presences": { // User presence state
"[email protected]": {
"lastKnownPresence": "unavailable | composing | recording ...", // Last known state
"lastSeen": 1672004025 // Last seen timestamp
}
}
},
"instance": { // Chat instance details
"owner": "[email protected]",
"name": "codechat",
"id": "d4a58666-9737-485d-988b-d18a43ce8c75"
}
}