Package com.vonage.client.messages
Class InboundMessage
java.lang.Object
com.vonage.client.JsonableBaseObject
com.vonage.client.messages.InboundMessage
- All Implemented Interfaces:
Jsonable
Convenience class representing an inbound message webhook. This maps all known fields for all message types.
Refer to the Messages API Webhook reference for more details on the response object structure.
- Since:
- 7.2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected InboundMessage.UrlWrapperprotected Buttonprotected Channelprotected Stringprotected InboundMessage.UrlWrapperprotected Stringprotected InboundMessage.UrlWrapperWithCaptionprotected MessageTypeprotected UUIDprotected InboundMessage.Originprotected Reactionprotected SmsInboundMetadataprotected InboundMessage.UrlWrapperprotected Stringprotected Instantprotected Stringprotected MessageStatus.Usageprotected InboundMessage.UrlWrapperprotected InboundMessage.UrlWrapperprotected Contextprotected ContextStatusprotected Locationprotected Orderprotected Profileprotected Reply -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InboundMessageConstructs an instance of this class from a JSON payload.If getMessageType() is MessageType.AUDIO, returns the URL of the audio.If getMessageType() is MessageType.BUTTON, returns the button.The service used to send the message.The client reference will be present if set in the original outbound message.If the getChannel() is Channel.MMS, returns a list of one or more objects representing image, audio, video, vCard, or file attachments.If getMessageType() is MessageType.FILE, returns the URL of the file.getFrom()The number this message was sent from.Additional text accompanying the image.If getMessageType() is MessageType.IMAGE, returns the URL of the image.The media type of the message.Unique identifier of the message that was sent.If the getChannel() is Channel.SMS or Channel.MMS, return the network code from which the message originated (if available).If getMessageType() is MessageType.REACTION, returns the reaction.The URL for the message resource, including the geo-specific base URI.If the getChannel() is Channel.SMS, returns additional information about the message.If getMessageType() is MessageType.STICKER, returns the URL of the sticker.getText()If getMessageType() is MessageType.TEXT, returns the message text.The datetime of when the event occurred.getTo()The number this message was sent to.This is a catch-all method which encapsulates all fields in the response JSON that are not already a field in this class.getUsage()If the getChannel() is Channel.SMS, returns the usage information (charged incurred for the message).If getMessageType() is MessageType.VCARD and getChannel() is Channel.RCS, returns the name of the vCard.If getMessageType() is MessageType.VCARD, returns the URL of the vCard.If getMessageType() is MessageType.VIDEO, returns the URL of the video.If the getChannel() is Channel.WHATSAPP, returns the WhatsApp message context.If the getChannel() is Channel.WHATSAPP, returns an enum indicating whether there is a context for this inbound message.If getMessageType() is MessageType.LOCATION and getChannel() is Channel.WHATSAPP, returns the location.If the getChannel() is Channel.WHATSAPP, returns information about the sender's WhatsApp profile.If the getChannel() is Channel.WHATSAPP and a content referral is present in the message, returns the metadata related to the post or advertisement that the user clicked on.Methods inherited from class com.vonage.client.JsonableBaseObject
createJsonObjectMapper, equals, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.vonage.client.Jsonable
toJson, updateFromJson
-
Field Details
-
unknownProperties
-
timestamp
-
channel
-
messageType
-
messageUuid
-
to
-
from
-
clientRef
-
text
-
image
-
audio
-
video
-
file
-
vcard
-
sticker
-
reaction
-
button
-
whatsappProfile
-
whatsappContextStatus
-
whatsappContext
-
whatsappLocation
-
whatsappReply
-
whatsappOrder
-
usage
-
smsMetadata
-
origin
-
-
-
Constructor Details
-
InboundMessage
protected InboundMessage()
-
-
Method Details
-
getUnmappedProperties
This is a catch-all method which encapsulates all fields in the response JSON that are not already a field in this class.- Returns:
- The Map of unknown properties to their values.
-
getMessageType
The media type of the message.- Returns:
- The message type, as an enum.
-
getChannel
The service used to send the message.- Returns:
- The channel, as an enum.
-
getMessageUuid
Unique identifier of the message that was sent.- Returns:
- The UUID of the message.
-
getTo
The number this message was sent to.- Returns:
- The recipient number or ID.
-
getFrom
The number this message was sent from.- Returns:
- The sender number or ID.
-
getTimestamp
The datetime of when the event occurred.- Returns:
- The timestamp as an Instant.
-
getClientRef
The client reference will be present if set in the original outbound message.- Returns:
- The client reference, or
nullif unset.
-
getSelfUrl
The URL for the message resource, including the geo-specific base URI.- Returns:
- The
_self.hrefproperty as a URI, ornullif absent. - Since:
- 8.11.0
-
getText
If getMessageType() is MessageType.TEXT, returns the message text.- Returns:
- The message text, or
nullif not applicable.
-
getImageUrl
If getMessageType() is MessageType.IMAGE, returns the URL of the image.- Returns:
- The image URL, or
nullif not applicable.
-
getImageCaption
Additional text accompanying the image. Applicable to MMS image messages only.- Returns:
- The image caption if present, or
nullif not applicable. - Since:
- 8.1.0
-
getAudioUrl
If getMessageType() is MessageType.AUDIO, returns the URL of the audio.- Returns:
- The audio URL, or
nullif not applicable.
-
getVideoUrl
If getMessageType() is MessageType.VIDEO, returns the URL of the video.- Returns:
- The video URL, or
nullif not applicable.
-
getFileUrl
If getMessageType() is MessageType.FILE, returns the URL of the file.- Returns:
- The file URL, or
nullif not applicable.
-
getVcardUrl
If getMessageType() is MessageType.VCARD, returns the URL of the vCard.- Returns:
- The vCard URL, or
nullif not applicable.
-
getVcardName
If getMessageType() is MessageType.VCARD and getChannel() is Channel.RCS, returns the name of the vCard.- Returns:
- The vCard attachment file name, or
nullif absent / not applicable. - Since:
- 8.11.0
-
getStickerUrl
If getMessageType() is MessageType.STICKER, returns the URL of the sticker.- Returns:
- The sticker URL, or
nullif not applicable.
-
getReaction
If getMessageType() is MessageType.REACTION, returns the reaction.- Returns:
- The reaction details, or
nullif not applicable. - Since:
- 8.11.0
-
getButton
If getMessageType() is MessageType.BUTTON, returns the button.- Returns:
- The button details, or
nullif not applicable. - Since:
- 8.11.0
-
getProviderMessage
If getChannel() is Channel.WHATSAPP, returns theprovider_messagefield. This is a message from the channel provider, which may contain a description, error codes or other information.- Returns:
- The provider message or
nullif not applicable.
-
getWhatsappLocation
If getMessageType() is MessageType.LOCATION and getChannel() is Channel.WHATSAPP, returns the location.- Returns:
- The deserialized WhatsApp location, or
nullif not applicable.
-
getWhatsappReply
- Returns:
- The deserialized WhatsApp reply, or
nullif not applicable.
-
getWhatsappOrder
- Returns:
- The deserialized WhatsApp order, or
nullif not applicable.
-
getWhatsappProfile
If the getChannel() is Channel.WHATSAPP, returns information about the sender's WhatsApp profile.- Returns:
- The deserialized WhatsApp profile, or
nullif not applicable.
-
getWhatsappContext
If the getChannel() is Channel.WHATSAPP, returns the WhatsApp message context. This is only present where the user is quoting another message. It provides information about the quoted message and/or the product message being responded to.- Returns:
- The deserialized WhatsApp context, or
nullif not applicable.
-
getWhatsappContextStatus
If the getChannel() is Channel.WHATSAPP, returns an enum indicating whether there is a context for this inbound message. If there is a context, and it is available, the context details will be contained in a context object. If there is a context, but it is unavailable,or if there is no context for message (ContextStatus.NONE), then there will be no context object included in the body.- Returns:
- The deserialized WhatsApp context status, or
nullif not applicable. - Since:
- 8.1.0
-
getUsage
If the getChannel() is Channel.SMS, returns the usage information (charged incurred for the message).- Returns:
- The deserialized usage object, or
nullif not applicable.
-
getSmsMetadata
If the getChannel() is Channel.SMS, returns additional information about the message.- Returns:
- The SMS metadata, or
nullif not applicable.
-
getNetworkCode
If the getChannel() is Channel.SMS or Channel.MMS, return the network code from which the message originated (if available).- Returns:
- The origin network code if applicable, or
nullif unknown. - Since:
- 8.7.0
-
getWhatsappReferral
If the getChannel() is Channel.WHATSAPP and a content referral is present in the message, returns the metadata related to the post or advertisement that the user clicked on.- Returns:
- The Whatsapp referral object, or
nullif not present or applicable. - Since:
- 8.1.0
-
getContent
If the getChannel() is Channel.MMS, returns a list of one or more objects representing image, audio, video, vCard, or file attachments. Only present for messages that have more than one attachment.- Returns:
- The list of MMS attachments, or
nullif not applicable. - Since:
- 8.11.0
-
fromJson
Constructs an instance of this class from a JSON payload. Known fields will be mapped, whilst unknown fields can be manually obtained through the getUnmappedProperties() method.- Parameters:
json- The webhook response JSON string.- Returns:
- The deserialized webhook response object.
- Throws:
VonageResponseParseException- If the response could not be deserialized.
-