The Messages API enables you to connect with your customers over many social-messaging channels such as WhatsApp, Facebook Messenger, and Viber.

The connection is two-way; you can both send and receive messages. But in the rapidly evolving world of social-messaging channels, there’s a unique issue. What happens if a customer manages to send a message type to your business that is not yet supported?

Case in point, what happens when your customer sends you a sticker via WhatsApp? This question is pervasive for folks integrating with the Messages API.

The answer lies in the request body of the inbound message. The JSON of the inbound message contains a type field inside the message’s content object.

If the type is unsupported, the type field is unsupported; this is true for WhatsApp, Viber, Facebook Messenger, and MMS. The message body for an inbound message with an unsupported payload will look like this:

{
  "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab",
  "timestamp": "2020-01-01T14:00:00.000Z",
  "to": {
    "type": "whatsapp",
    "number": "447700900000"
  },
  "from": {
    "type": "whatsapp",
    "number": "447700900001"
  },
  "message": {
    "content": {
      "type": "unsupported"
    }
  }
}

#nodejs #vonage-api #node-js-development #messages-api #node-js-tutorial #node

Handling Unsupported Inbound Messages With the Messages API
1.45 GEEK