Chat Module Ingest Events
Kenkai SDK Chat Module tracks the messages and other activity events from the managed groups in order to facilitate engagement analysis.
List of Events
| Event Name | Type | Description |
|---|---|---|
| Message | message | Track events related to messages, including standard messages, replies, and reactions |
| Group | group | Track group-related events, e.g. user joined/left, group created/deleted, etc. |
| Receipt | receipt | Track message status events, e.g. message sent, delivered, read etc. |
Message Event
A message event indicates if a message of a certain type has been sent directly to the bot or the managed group.
Format
| Param | Usability | Format | Enum Values | Description |
|---|---|---|---|---|
| platform | REQUIRED | STRING | whatsapp, telegram, other | Source platform |
| msg_id | REQUIRED | STRING | Globally unique identifier of the message | |
| sender_type | REQUIRED | STRING | user, bot | The entity type who sent this message |
| sender_id | REQUIRED | STRING | Globally unique identifier of the sender of this message | |
| recipient_type | REQUIRED | STRING | user, group | The entity type who received this message |
| recipient_id | OPTIONAL | STRING | Globally unique identifier of the receiver of this message | |
| parent_msg_id | OPTIONAL | STRING | The identifier of the previous message in the reply chain | |
| type | REQUIRED | STRING | text, audio, document, image, video, sticker, contact, poll, reaction | Type of the message's content |
| body | REQUIRED | JSONB | Content object, with structure determined by the type utf-8 text |
Usage
- JSON type=`text`
- JSON type=`audio
- JSON type=`document`
- JSON type=`image`
- JSON type=`reaction`
{
"ts": "2024-02-13 15:09:20Z",
"type": "message",
"props": {
"platform": "whatsapp",
"msg_id": "3c6b469b-ef05-492d-988c-add03cf260de",
"sender_type": "bot",
"sender_id": "913c37fd-341b-42d5-9814-0a061c45617e",
"recipient_type": "user",
"recipient_id": "1e7c1a8b-c291-48df-9ad2-55aecd684270",
"parent_msg_id": null,
"type": "text",
"body": {
"text": "'Lorem ipsum' on the docs page! 🚀"
}
}
}
{
"ts": "2024-02-13 15:09:20Z",
"type": "message",
"props": {
"platform": "whatsapp",
"msg_id": "3c6b469b-ef05-492d-988c-add03cf260de",
"sender_type": "bot",
"sender_id": "913c37fd-341b-42d5-9814-0a061c45617e",
"recipient_type": "user",
"recipient_id": "1e7c1a8b-c291-48df-9ad2-55aecd684270",
"parent_msg_id": null,
"type": "audio",
"body": {
"sha256": "1474ee4302163ef8016e9ec0dc6f2dc1f387fcd285797f3b1a3eeefca3d2e148", // optional
"mime_type": "audio/mpeg",
"base64": "/+MYxAAAAANIAAAAAExBTUUzLjk4L..."
}
}
}
{
"ts": "2024-02-13 15:09:20Z",
"type": "message",
"props": {
"platform": "whatsapp",
"msg_id": "3c6b469b-ef05-492d-988c-add03cf260de",
"sender_type": "bot",
"sender_id": "913c37fd-341b-42d5-9814-0a061c45617e",
"recipient_type": "user",
"recipient_id": "1e7c1a8b-c291-48df-9ad2-55aecd684270",
"parent_msg_id": null,
"type": "document",
"body": {
"sha256": "1474ee4302163ef8016e9ec0dc6f2dc1f387fcd285797f3b1a3eeefca3d2e148", // optional
"mime_type": "application/pdf",
"base64": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9UeXBlL1BhZ2UvUG..."
}
}
}
{
"ts": "2024-02-13 15:09:20Z",
"type": "message",
"props": {
"platform": "whatsapp",
"msg_id": "dba92739-0d4f-49bf-9bd4-0f2116d49221",
"sender_type": "bot",
"sender_id": "913c37fd-341b-42d5-9814-0a061c45617e",
"recipient_type": "user",
"recipient_id": "1e7c1a8b-c291-48df-9ad2-55aecd684270",
"parent_msg_id": "3c6b469b-ef05-492d-988c-add03cf260de",
"type": "image",
"body": {
"sha256": "1474ee4302163ef8016e9ec0dc6f2dc1f387fcd285797f3b1a3eeefca3d2e148", // optional
"caption": "A variety of emoji as they appear on Google's Noto Color Emoji set as of 2024",
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5d/Noto_Color_Emoji_From_Each_Unicode_Emoji_Category.jpg",
"mime_type": "image/jpeg",
"base64": "/9j/4Rk8RXhpZgAATU0AKgAAAAgABw..." // at least one of url or base64 is required
}
}
}
{
"ts": "2024-02-13 15:09:20Z",
"type": "message",
"props": {
"platform": "whatsapp",
"msg_id": "3c6b469b-ef05-492d-988c-add03cf260de",
"sender_type": "bot",
"sender_id": "1e7c1a8b-c291-48df-9ad2-55aecd684270",
"recipient_type": "user",
"recipient_id": null,
"parent_msg_id": null,
// content block for a 🤗 reaction
"type": "reaction",
"body": {
"emoji": "\uD83E\uDD17"
}
}
}
Group Event
A group event reflects the members of a managed chat group.
Format
| Param | Usability | Format | Enum Values | Description |
|---|---|---|---|---|
| group_id | REQUIRED | STRING | Globally unique identifier of the group | |
| type | REQUIRED | STRING | join, leave, remove, create, update, delete | Group management event type |
| member_type | OPTIONAL | STRING | user, bot | The type of the member this event is concerned with |
| member_id | OPTIONAL | STRING | Globally unique identifier of a member | |
| group_name | OPTIONAL | STRING | The name of the group | |
| description | OPTIONAL | STRING | The description of the group |
- JSON type=`join`
- JSON type=`create`
{
"type": "group",
"props": {
"type": "join",
"group_id": "4bbaf4a2-1136-4888-ba9f-1e205ea1bed9",
"member_type": "user",
"member_id": "1e7c1a8b-c291-48df-9ad2-55aecd684270"
}
}
{
"type": "group",
"props": {
"type": "create",
"group_id": "4bbaf4a2-1136-4888-ba9f-1e205ea1bed9",
"group_name": "Ceci n'est pas un lorem ipsum dolor",
"description": "Sightings of 'lorem ipsum' in the wild"
}
}
Receipt Event
An event reflecting change in the status of a message.
Format
| Param | Usability | Format | Enum Values | Description |
|---|---|---|---|---|
| msg_id | REQUIRED | STRING | Globally unique identifier of the message | |
| type | REQUIRED | STRING | sent, failed, deleted, delivered, read | Type of the message receipt |
| member_id | OPTIONAL | STRING | Globally unique identifier of a member who generated this receipt |
"Message Delivery Receipts"
Some platforms may even send receipts of message delivery apart from read receipts
- JSON type=`sent`
- JSON type=`read`
{
"ts": "2024-02-13 15:09:20Z",
"type": "group",
"props": {
"type": "sent",
"msg_id": "dba92739-0d4f-49bf-9bd4-0f2116d49221"
}
}
{
"ts": "2024-02-13 15:09:20Z",
"type": "group",
"props": {
"type": "read",
"msg_id": "3c6b469b-ef05-492d-988c-add03cf260de",
"member_id": "1e7c1a8b-c291-48df-9ad2-55aecd684270"
}
}