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

Configuring an instance

To receive incoming notifications about text messages, you need to enable the settings using one of the following options:

  1. Through console enable the setting Get notifications about incoming messages and files

  2. Through the SetSettings method enable the setting incomingWebhook

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 message from group chat webhook body example#

{
    "typeWebhook": "incomingMessageReceived",
    "instanceData": {
        "idInstance": 1234,
        "wid": "11001234567@c.us",
        "typeInstance": "whatsapp"
    },
    "timestamp": 1732268220,
    "idMessage": "2D9D6721A977D369246509EBE0CE44CA",
    "senderData": {
      "chatId": "120363369140947676@g.us",
      "chatName": "Group",
      "sender": "79001234568@c.us",
      "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": "46618B98B3B9DF50F123456789123456",
      "participant": "79001234568@c.us"
    },
    "quotedMessage": {
      "stanzaId": "46618B98B3B9DF50F123456789123456",
      "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": "46618B98B3B9DF50F123456789123456",
      "participant": "79001230000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "46618B98B3B9DF50F123456789123456",
      "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": "46618B98B3B9DF50F123456789123456",
      "participant": "79001230000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "46618B98B3B9DF50F123456789123456",
      "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": "46618B98B3B9DF50F123456789123456",
      "participant": "79001230000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "46618B98B3B9DF50F123456789123456",
      "participant": "79060002233@c.us",
      "typeMessage": "locationMessage",
      "location": {
        "nameLocation": "",
        "address": "",
        "jpegThumbnail": "",
        "latitude": 72.5922702,
        "longitude": 39.6645388
      }
    }
  }
}
{
  "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": "46618B98B3B9DF50F123456789123456",
      "participant": "79000000000@c.us"
    },
    "quotedMessage": {
      "stanzaId": "46618B98B3B9DF50F123456789123456",
      "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}}"
        }
    }
}

Webhook body example with error SWE999#

{
    "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 Doe",
    "senderContactName": "John Doe"
    },
    "messageData":
        {
        "typeMessage":"textMessage",
        "textMessageData":
            {
            "textMessage":"{{SWE999}}"
        }
    }
}