Incoming Messages on Webhook

When a user sends a message to Business, it's termed as Incoming Message for the business. Such messages are posted to to Webhook at real time with a JSON Payload of predefined format.

Type of Incoming Messages

Following type of messages are considered incoming messages:

  • Text: Text messages are freeform responses.
  • Suggestions: Suggestion messages are generated by user’s action on the message. Messages include the postback data and text of the suggested action or suggested reply that the user tapped.
  • Location: Location messages include latitude and longitude values.
  • File: File messages include the URI for a file and associated data.

Note

  • All incoming messages from users follows a pre-defined Format.
  • This page covers only "Text" and "File" type of respones.
  • For "Location" and "Suggestions" type of messages, click here.

Standard JSON Format

{
"agent": "{agent name}",
"phone": "{user phone}",
"request_id": "{request_id}",
"session_id": "{session id}",
"type": "{msg type}",
// more object/keys will appear here
// related to different type of content
"timestamp": "{send time in UTC}",
}

JSON Explanation

Key / ObjectData TypeDescription
agentStringName of RBM Agent
phoneStringPhone number of the person who sent the message to business
request_idStringUnique Request ID. Incoming Messages are identified by Request ID
session_idStringSession ID of follow-up conversation
typeStringEnumerated values: text, suggestion, file, location
timestampStringTime when its sent by Sender. In UTC. Format: YYYY-MM-DDTHH:II:SS.000Z

Text Message

JSON Payload

{
"agent": "{agent name}",
"phone": "{user phone}",
"request_id": "{request_id}",
"session_id": "{session id}",
"type": "text",
"text": "{Text Message}"
"timestamp": "{send time in UTC}",
}

JSON Explanation: Covers only key/objects related to 'text` Content. For other keys, refer Standard JSON Format explained above.

Key / ObjectData TypeDescription
typeStringIt comes as text
textStringPlain text content

Message with Rich Media File

JSON Payload

{
"agent": "{agent name}",
"phone": "{user phone}",
"request_id": "{request_id}",
"session_id": "{session id}",
"type": "file",
"file": {
"media": "image",
"$media": {
"mimeType": "{mime type}",
"fileSizeBytes": {file size},
"fileUri": "{https url of file}",
"fileName": "{file name}"
}
},
"timestamp": "{send time in UTC}",
}

JSON Explanation: Covers only key/objects related to 'text` Content. For other keys, refer Standard JSON Format explained above.

Key / ObjectData TypeDescription
typeStringIt comes as file
fileObjectContains main media file information
file.mediaStringType of media file. Enumerated values: image, video, document
file.$mediaObject$media is named after value of file.media. For Example, if file.media:video, then $media object be named as video

JSON Explanation: Covers only media information in $media object, viz.

Key / ObjectData TypeDescription
mimeTypeStringMime type of image, e.g. image/jpeg
fileSizeBytesNumbeerFile Size (In byte)
fileUriStringAccess URL for the file
fileNameStringName of the file