Skip to content

Events Callbacks

Follow each event as it happens

Sent Message Status Event


Receive an event every time you send a message to a contact with the states: failed, pending, sent, received or read

javascript
//event:any
const client = await superchats.create({
  session: "Marketing",
  license: "asjdh-efddff734-sdsdf834-233272",
  onAck: (event) => {
     console.log(event)
})

Return from onAck event

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-ack",
  "status": "SEND",
  "device_default": true, // Marca verdadeiro (Quando é o Aparelho com Whatsapp Instalado)
  "id": "KIZAKIXDECF7177340C7",
  "to": "556191922853"
}

Message Receiving and Sending Event


Receive an event every time you receive and send a message to a contact

javascript
//event:any
const client = await superchats.create({
  session: "Marketing",
  license: "asjdh-efddff734-sdsdf834-233272",
  onAnyMessage: (event) => {
     console.log(event)
})

Returning the OnAnyMessage event for sent messages

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-any-message",
  "subevent": "sending",
  "type": "textMessage",
  "isMedia": false,
  "pushName": "",
  "id": "KIZAKIXDECF7177340C7",
  "from": "556191922853",
  "content": {
    "textMessage": {
      "text": "Olá como vai?"
    }
  },
  "isgroup": false,
  "participant": "",
  "timestamp": 1714695309
}

Returning the OnAnyMessage event for received messages

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-any-message",
  "subevent": "received",
  "type": "textMessage",
  "isMedia": false,
  "pushName": "Joe Dutra",
  "id": "3EB060222C415FAE425ECA",
  "from": "556191922853",
  "content": {
    "textMessage": {
      "text": "como vai?"
    }
  },
  "isgroup": false,
  "participant": "",
  "timestamp": 1714695173
}

Return of the Deleted Messages OnAnyMessage event

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-any-message",
  "subevent": "received",
  "type": "deleteMessage",
  "isMedia": false,
  "pushName": "Joe Dutra",
  "id": "3EB0B9934B7364E7130199",
  "from": "556191922853",
  "content": {
    "deleteMessage": {
      "key": {
        "remoteJid": "551152204957@s.whatsapp.net",
        "fromMe": true,
        "id": "3EB09F2EB272C0B4C47692"
      }
    }
  },
  "isgroup": false,
  "participant": "",
  "timestamp": 1714935876
}

Return of the OnAnyMessage event from replied messages

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-any-message",
  "subevent": "received",
  "type": "on-any-message",
  "isMedia": false,
  "pushName": "Joe Dutra",
  "id": "3EB000A52433005679333D",
  "from": "556191922853",
  "content": {
    "replyMessage": {
      "text": "oi como vai?",
      "contextInfo": {
        "stanzaId": "3EB09875B6E5D95AB7FC5D",
        "participant": "556191922853@s.whatsapp.net",
        "quotedMessage": {
          "extendedTextMessage": {
            "text": "oi",
            "inviteLinkGroupTypeV2": "DEFAULT"
          }
        }
      }
    }
  },
  "isgroup": false,
  "participant": "",
  "timestamp": 1714936156
}

Return of the Edited Messages OnAnyMessage event

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-any-message",
  "subevent": "received",
  "type": "editedMessage",
  "isMedia": false,
  "pushName": "Joe Dutra",
  "id": "3EB04761BBBE0D42B4EA",
  "from": "556191922853",
  "content": {
    "editedMessage": {
      "key": {
        "remoteJid": "551152204957@s.whatsapp.net",
        "fromMe": true,
        "id": "3EB0487937116C942FA9CE"
      },
      "editedMessage": {
        "conversation": "oi Olá kkk"
      },
      "timestampMs": {
        "low": 1245068041,
        "high": 399,
        "unsigned": false
      }
    }
  },
  "isgroup": false,
  "participant": "",
  "timestamp": 1714937019
}

Returning the OnAnyMessage event from Reacted Messages

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-any-message",
  "subevent": "received",
  "type": "reactionMessage",
  "isMedia": false,
  "pushName": "Joe Dutra",
  "id": "3EB07E40491A6CA7D5E6E2",
  "from": "556191922853",
  "content": {
    "reactionMessage": {
      "key": {
        "remoteJid": "556191922853@s.whatsapp.net",
        "fromMe": true,
        "id": "KIZAKIXDE4076D9A9801"
      },
      "text": "👍",
      "senderTimestampMs": "1714938427000"
    }
  },
  "isgroup": false,
  "participant": "",
  "timestamp": 1714938428
}

Presence Event


Receive an event whenever a contact is: typing, recording, online or offline with you
Status types: available, composing, recording and paused

javascript
//event:any
const client = await superchats.create({
  session: "Marketing",
  license: "asjdh-efddff734-sdsdf834-233272",
  onPresence: (event) => {
     console.log(event)
})

Return from onPresence event

javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "from": '556181590153',
  "status": 'composing',
  "pushname": 'Joe Dutra'
}

Connection Event


Receive an event whenever you receive a voice or video call
Status types: available, composing, recording and paused

javascript
//event:any
const client = await superchats.create({
  session: "Marketing",
  license: "asjdh-efddff734-sdsdf834-233272",
  onCall: (event) => {
     console.log(event)
})

Return from onCall event

javascript
{
  "session": "1",
  "device": "551152204957",
  "event": "on-call",
  "id": "5A85E5CD48CDE7EC258D26E9A8B2F643",
  "from": "556191922853",
  "date": "2024-05-03T00:25:43.000Z",
  "offline": false,
  "status": "ringing",
  "isVideo": false,
  "isGroup": false
}

Data Synchronization Event


Receive events whenever you read the Qrcode and the data is synchronized

javascript
//event:any
const client = await superchats.create({
  session: "Marketing",
  license: "asjdh-efddff734-sdsdf834-233272",
  syncHistory: (event) => {
     console.log(event)
})

Return from the syncHistory event

javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "type": 'sync-progress',
  "percent": 100
}

Group Events


Receive events whenever a group name, settings change
Return types: change-name, change-messages-admin, change-settings-admin and paused

javascript
//event:any
const client = await superchats.create({
  session: "Marketing",
  license: "asjdh-efddff734-sdsdf834-233272",
  onGroups: (event) => {
     console.log(event)
})

Return from onGroup event

Change Group Name
javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "action": 'change-name',
  "changed": [ 'Grupo Live', 'Teste Grupo Live' ],
  "group": 'Grupo Live',
  "from": '15795662985-1631581942',
  "participant": '15795662985',
  "participants": 3
}
Group changes for admin-only messages
javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "action": 'change-messages-admin',
  "changed": 'active',
  "group": 'Grupo Live',
  "from": '15795662985-1631581942',
  "participant": '15795662985',
  "participants": 3
}
Group changes in settings for admins only
javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "action": 'change-settings-admin',
  "changed": 'active',
  "group": 'Grupo Live',
  "from": '15795662985-1631581942',
  "participant": '15795662985',
  "participants": 3
}

Participant Events


Receive events about group participants

Types of action: add, remove, promote and demote

javascript
//event:any
const client = await superchats.create({
  session: "Marketing",
  license: "asjdh-efddff734-sdsdf834-233272",
  onParticipants: (event) => {
     console.log(event)
})

Return of the onParticipants event

Participants Added
javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "group": 'Grupo Live',
  "from": '15795662985-1631581942',
  "participant": '5521991977392',
  "action": 'add',
  "participants": 3
}
Participants Removed
javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "group": 'Grupo Live',
  "from": '15795662985-1631581942',
  "participant": '5521991977392',
  "action": 'remove',
  "participants": 2
}
javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "group": 'Grupo Live',
  "from": '15795662985-1631581942',
  "participant": '5521991977392',
  "action": 'promote',
  "participants": 3
}
Participants Removed
javascript
{
  "session": 'Marketing',
  "device": "551152204957",
  "group": 'Grupo Live',
  "from": '15795662985-1631581942',
  "participant": '5521991977392',
  "action": 'demote',
  "participants": 3
}

All rights reserved to Orkestral LLC