Skip to main content

XMessage

Introduction

XMessage is a custom data structure designed for facilitating communication between services within the BharatSahAIyak ecosystem. It serves as a comprehensive format for encapsulating various types of messages exchanged between different components or modules.

Components of XMessage

XMessage consists of several components, each serving a specific purpose:

Field NameDescriptionType
messageTypeRepresents the type of message being sent.MessageType
messageIdUniquely identifies each message and may contain additional identifiers for referencing related messages or channels.MessageId
toContains details about the sender and recipient(s) of the message.SenderReceiverInfo
fromContains details about the sender of the message.SenderReceiverInfo
channelURISpecifies the channel through which the message is being sent.string
providerURISpecifies the provider through which the message is being sent.string
timestampIndicates the time at which the message was sent.Unix Timestamp
messageStateReflects the current state of the message.MessageState
payloadCarries the actual content of the message.XMessagePayload
tagsOptional array of tags associated with the message.Array of strings

Components Details

Message Type

TypeDescription
TEXTRepresents a text message.
IMAGERepresents an image message.
VIDEORepresents a video message.
AUDIORepresents an audio message.
LOCATIONRepresents a location message.
DOCUMENTRepresents a document message.
REGISTRATIONRepresents a registration message.
FEEDBACK_NEGATIVERepresents a negative feedback message.
FEEDBACK_POSITIVERepresents a positive feedback message.
FEEDBACK_NEUTRALRepresents a neutral feedback message.
HSMRepresents a Highly Structured Message.

Message ID

FieldDescriptionType
IdUnique identifier for the message.string (UUID)
channelMessageIdIdentifier specific to the communication channel.string
replyIdIdentifier for referencing a reply message.string (UUID)

Sender and Receiver Information

FieldDescriptionType
userIDIdentifier of the user.string
groupsList of groups the user belongs to.Array<string>
campaignIDIdentifier of the campaign.string
formIDIdentifier of the form.string
botStatus of the bot (if applicable).boolean
broadcastStatus of broadcast (if applicable).boolean
deviceTypeType of device used.string
deviceIDIdentifier of the device.string
encryptedDeviceIDEncrypted identifier of the device (if present).string
metaAdditional metadata related to sender/receiver.Map<string, string>

Channel and Provider Information

FieldDescriptionType
ChannelCommunication channel.String
ProviderService provider involved in message delivery.String

Message State

StateDescription
NOT_SENTMessage failed to be sent.
FAILED_TO_DELIVERMessage failed to be delivered.
DELIVEREDMessage has been successfully delivered.
READMessage has been read by the recipient.
REPLIEDA reply has been sent for this message.
ENQUEUEDMessage is enqueued for sending.
SENTMessage has been successfully sent.
OPTED_INRecipient has opted in to receive messages.
OPTED_OUTRecipient has opted out from receiving messages.

Payload Fields

FieldDescriptionType
textText content of the message.string
mediaMedia content of the message (e.g., image, video).MessageMedia
locationLocation parameters if applicable.LocationParams
contactCardContact card information.ContactCard
buttonChoicesArray of button choices for interactive messages.Array<ButtonChoice>
stylingTagStyling tag for message formatting.StylingTag
flowFlow identifier for message handling.string
questionIndexIndex of the question within a flow.number
mediaCaptionCaption for media content.string
metaDataAdditional metadata associated with the message.Record<string, any>
subjectSubject of the message.string