Skip to content

Incoming text message#

This section describes messageData object incoming webhook format for incoming text message. For a description of the general format of incoming webhooks, refer to Incoming messages section.

To get incoming webhooks of this type, two conditions must be true:

typeWebhook = incomingMessageReceived

messageData.typeMessage = textMessage

Webhook#

Webhook parameters#

messageData object parameters

Parameter Type Descriptionе
typeMessage string Received message type. For messages of this type, the parameter takes on the value textMessage
textMessageData object Text message data object
quotedMessage object Quoted message data object. Present only if the message itself is a quote

textMessageData object parameters

Parameter type Description
textMessage string Text message
isTemplateMessage boolean The flag indicates whether the message was generated from a template

quotedMessage object parameters

Parameter Type Description
stanzaId string Quoted message id
participant string Quoted message sender's id
typeMessage string Quoted message type

The rest of the fields are filled depending on the type of the quoted message and are identical to the fields of incoming messages described in Incoming messages section

Webhook body example#

{
  "typeWebhook": "incomingMessageReceived",
  "instanceData": {
    "idInstance": 1234,
    "wid": "11001234567@c.us",
    "typeInstance": "whatsapp"
  },
  "timestamp": 1588091580,
  "idMessage": "F7AEC1B7086ECDC7E6E45923F5EDB825",
  "senderData": {
    "chatId": "79001234568@c.us",
    "sender": "79001234568@c.us",
    "chatName": "John",
    "senderName": "John",
    "senderContactName": "John Doe"
  },
  "messageData": {
    "typeMessage": "textMessage",
    "textMessageData": {
      "textMessage": "I use Green-API to send this message to you!"
    }
  }
}

Text quoted message webhook body example#

{
  "typeWebhook": "incomingMessageReceived",
  "instanceData": {
    "idInstance": 1234,
    "wid": "11001234567@c.us",
    "typeInstance": "whatsapp"
  },
  "timestamp": 1588091580,
  "idMessage": "F7AEC1B7086ECDC7E6E45923F5EDB825",
  "senderData": {
    "chatId": "79001234568@c.us",
    "sender": "79001234568@c.us",
    "chatName": "John",
    "senderName": "John",
    "senderContactName": "John Doe"
  },
  "messageData": {
    "typeMessage": "quotedMessage",
    "extendedTextMessageData": {
      "text": "Это",
      "stanzaId": "B7F33B8947D872F30FAA646FEDCDE2EC",
      "participant": "79001234568@c.us"
    },
    "quotedMessage": {
      "stanzaId": "9A73322488DCB7D9689A6112F2528C9D",
      "participant": "79001234568@c.us",
      "typeMessage": "textMessage",
      "textMessage": "Hello"
    }
  }
}

Image/video/audio/document quote text message body example#

{
  "typeWebhook": "incomingMessageReceived",
  "instanceData": {
    "idInstance": 1234,
    "wid": "11001234567@c.us",
    "typeInstance": "whatsapp"
  },
  "timestamp": 1588091580,
  "idMessage": "F7AEC1B7086ECDC7E6E45923F5EDB825",
  "senderData": {
    "chatId": "79001234568@c.us",
    "sender": "79001234568@c.us",
    "chatName": "John",
    "senderName": "John",
    "senderContactName": "John Doe"
  },
  "messageData": {
    "typeMessage": "quotedMessage",
    "extendedTextMessageData": {
      "text": "Ответ",
      "stanzaId": "B4AA239D112CB2576897B3910FEDE26E",
      "participant": "79001230000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "9A73322488DCB7D9689A6112F2528C9D",
      "participant": "79061230000@c.us",
      "typeMessage": "imageMessage",
      "downloadUrl": "",
      "caption": "",
      "jpegThumbnail": ""
    }
  }
}

Contact quote message webhook body example#

{
  "typeWebhook": "incomingMessageReceived",
  "instanceData": {
    "idInstance": 1234,
    "wid": "11001234567@c.us",
    "typeInstance": "whatsapp"
  },
  "timestamp": 1588091580,
  "idMessage": "F7AEC1B7086ECDC7E6E45923F5EDB825",
  "senderData": {
    "chatId": "79001234568@c.us",
    "sender": "79001234568@c.us",
    "chatName": "John",
    "senderName": "John",
    "senderContactName": "John Doe"
  },
  "messageData": {
    "typeMessage": "quotedMessage",
    "extendedTextMessageData": {
      "text": "Ответ",
      "stanzaId": "B4AA239D112CB2576897B3910FEDE26E",
      "participant": "79001230000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "9A73322488DCB7D9689A6112F2528C9D",
      "participant": "79061230000@c.us",
      "typeMessage": "contactMessage",
      "contact": {
        "displayName": "Green-Api",
        "vcard": "BEGIN:VCARD\nVERSION:3.0\nN:Green-Api\nitem1.TEL;waid=79001230000\nitem1.X-ABLabel:Mobile\nEND:VCARD"
      }
    }
  }
}

Location quote message webhook body example#

{
  "typeWebhook": "incomingMessageReceived",
  "instanceData": {
    "idInstance": 1234,
    "wid": "11001234567@c.us",
    "typeInstance": "whatsapp"
  },
  "timestamp": 1588091580,
  "idMessage": "F7AEC1B7086ECDC7E6E45923F5EDB825",
  "senderData": {
    "chatId": "79001234568@c.us",
    "sender": "79001234568@c.us",
    "chatName": "John",
    "senderName": "John",
    "senderContactName": "John Doe"
  },
  "messageData": {
    "typeMessage": "quotedMessage",
    "extendedTextMessageData": {
      "text": "Address",
      "stanzaId": "CA5654B8E8806ED7D033E758E7463AB9",
      "participant": "79001230000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "9A73322488DCB7D9689A6112F2528C9D",
      "participant": "79060002233@c.us",
      "typeMessage": "locationMessage",
      "location": {
        "nameLocation": "",
        "address": "",
        "jpegThumbnail": "",
        "latitude": 72.5922702,
        "longitude": 39.6645388
      }
    }
  }
}

Link quote message webhook body example#

{
  "typeWebhook": "incomingMessageReceived",
  "instanceData": {
    "idInstance": 1234,
    "wid": "7000000000@c.us",
    "typeInstance": "whatsapp"
  },
  "timestamp": 1658261933,
  "idMessage": "CDF9219DD08D3D84CD4E621122AFBFFD",
  "senderData": {
    "chatId": "79000000000@c.us",
    "sender": "79000000000@c.us",
    "chatName": "John",
    "senderName": "John",
    "senderContactName": "John Doe"
  },
  "messageData": {
    "typeMessage": "quotedMessage",
    "extendedTextMessageData": {
      "text": "Hello",
      "stanzaId": "6FFC3BF49BEE0CF966397321C4E3D3DF",
      "participant": "79000000000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "9A73322488DCB7D9689A6112F2528C9D",
      "participant": "79000000000@c.us",
      "typeMessage": "extendedTextMessage",
      "textMessage": "https://api.greenapi.com/send/?phone=7000000000&text&type=phone_number&app_absent=0",
      "extendedTextMessage": {
        "description": " is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.",
        "title": "Share on ",
        "previewType": "None",
        "jpegThumbnail": null
      }
    }
  }
}

Webhook body example with error SWE001#

{
    "typeWebhook": "incomingMessageReceived",
    "instanceData":
        {
        "idInstance":1100000001,
        "wid":"79000000000@c.us",
        "typeInstance":"whatsapp"
    },
    "timestamp":1700545580,
    "idMessage":"3AE2864C77312000000",
    "senderData":
        {
        "chatId":"79000000001@c.us",
        "chatName":"John",
        "sender":"79000000001@c.us",
        "senderName":"John",
    "senderContactName": "John Doe"
    },
    "messageData":
        {
        "typeMessage":"textMessage",
        "textMessageData":
            {
            "textMessage":"{{SWE001}}"
        }
    }
}

Webhook body example with error SWE002#

{
    "typeWebhook":"incomingMessageReceived",
    "instanceData":
        {
        "idInstance":1100000001,
        "wid":"79000000000@c.us",
        "typeInstance":"whatsapp"
    },
    "timestamp":1700488335,
    "idMessage":"3EB0D00923D87A3FA01BAE",
    "senderData":
        {
        "chatId":"79000000000@c.us",
        "chatName":"John",
        "sender":"79000000000@c.us",
        "senderName":"John",
    "senderContactName": "John Doe"
    },
    "messageData":
        {
        "typeMessage":"documentMessage",
        "fileMessageData":
            {
            "downloadUrl":"{{SWE002}}",
            "caption":"",
            "fileName":"Harry Potter and the Philosopher's Stone.pdf",
            "jpegThumbnail":"",
            "mimeType":"application/pdf",
            "forwardingScore":0,
            "isForwarded":false
        }
    }
}

Webhook body example with error SWE003#

{
    "typeWebhook":"incomingMessageReceived",
    "instanceData":
        {
        "idInstance":1100000001,
        "wid":"79000000000@c.us",
        "typeInstance":"whatsapp"
    },
    "timestamp":1700218861,
    "idMessage":"6E112CC05BA05DD9DF",
    "senderData":
        {
        "chatId":"79000000000@c.us",
        "chatName":"John",
        "sender":"79000000000@c.us",
        "senderName":"John",
    "senderContactName": "John Doe"
        },
    "messageData":
                {
        "typeMessage":"textMessage",
        "textMessageData":
            {
            "textMessage":"{{SWE003}}"
        }
    }
}