All Products
Search
Document Center

Chat App Message Service:ChatAppInbound

Last Updated:Apr 19, 2024

Obtains mobile originated (MO) messages by specifying an HTTP URL.

Protocol

Parameter

Description

Protocol

HTTP + JSON

Encoding method

UTF-8

Request

A single push may contain multiple inbound messages.

Sample request where Type is set to TEXT

[
   {
   "MessageId": "1000000000000001",  
   "From": "861388888****",    
   "To": "86137888****",    
   "DisplayName": "Mr Liu",
   "Type": "TEXT",
   "Message": "hello,it's me",    
   "Timestamp": 1662104191973,
   "Name": "jack"
   },
   {
   "MessageId": "1000000000000002",  
   "From": "861388888****",    
   "To": "86139123****",    
   "DisplayName": "Mr Wang",
   "Type": "TEXT",
   "Message": "hello,it's me",    
   "Timestamp": 1662104191973,
   "Name": "Jones"
   }
]

Sample request where Type is set to AUDIO

[ 
   {    
   "MessageId": "1000000000000003",    
   "From": "+861388888****",     
   "DisplayName": "Mr Liu",        
   "To": "+861378886****",    
   "Type": "AUDIO",    
   "Message": 
            "{
             \"name\": \"this is first audio message\", 
             \"id\": \"6e098464-117c-480b-beaa-3ea0635f****\", 
             \"mimeType\": \"application/pdf\",
             \"fileName\": \"first.pdf\", 
             \"url\": \"\" 
             } ",    
   "Timestamp ": 1662104191973,        
   "Name": "jack"
   },
   {    
   "MessageId": "1000000000000004",    
   "From": "+861388888****",     
   "DisplayName": "Mr Wang",        
   "To": "+861378886****",    
   "Type": "AUDIO",    
   "Message": 
            "{
             \"name\": \"this is first audio message\", 
             \"id\": \"6e098464-117c-480b-beaa-3ea0635f****\", 
             \"mimeType\": \"application/pdf\",
             \"fileName\": \"first.pdf\", 
             \"url\": \"\" 
             } ",    
   "Timestamp ": 1662104191973,        
   "Name": "John"
   } 
]

Sample request where Type is set to DOCUMENT

[
   {    
   "MessageId": "1000000000000005",    
   "From": "+861388888****",         
   "DisplayName": "Mr Liu",    
   "To": "+861378889****",    
   "Type": "DOCUMENT",    
   "Message": 
            "{
             \"name\": \"this is first document message\", 
             \"ID\": \"6e098464-117c-480b-beaa-3ea0635f****\", 
             \"mimeType\": \"audio/ogg; codecs=opus\", 
             \"url\": \"\" 
             }" ,    
   "Timestamp ": 1662104191973,        
   "Name": "jack"
   },
   {    
   "MessageId": "1000000000000006",    
   "From": "+861388888****",         
   "DisplayName": "Mr Liu",    
   "To": "+861378882****",    
   "Type": "DOCUMENT",    
   "Message": 
            "{
             \"name\": \"this is first document message\", 
             \"ID\": \"6e098464-117c-480b-beaa-3ea0635f****\", 
             \"mimeType\": \"audio/ogg; codecs=opus\", 
             \"url\": \"\" 
             }" ,    
   "Timestamp ": 1662104191973,        
   "Name": "Jone"
   } 
]

Sample request where Type is set to REPLY

[
   {    
   "MessageId": "1000000000000007",    
   "From": "861388888****",        
   "DisplayName": "Mr Liu",    
   "To": "861378886****",    
   "Type": "REPLY",    
   "Message": "{ \"text\": \"click me\",\"payload\": \"1000000\" }" ,    
   "Timestamp ": 1662104191973
   },
   {    
   "MessageId": "1000000000000008",    
   "From": "861388888****",        
   "DisplayName": "Mr Wang",    
   "To": "861378883****",    
   "Type": "REPLY",    
   "Message": "{ \"text\": \"click me\",\"payload\": \"1000000\" }" ,    
   "Timestamp ": 1662104191973
   } 
]

Sample request where Type is set to LOCATION

[
   {    
   "MessageId": "1000000000000009",    
   "From": "861388888****",        
   "DisplayName":"Mr Liu",    
   "To": "861378868****",    
   "Type": "LOCATION",    
   "Message": "{\"address \": \"changsha yuelu street \", \"latitude \": \"39.999137107913\", \"longitude \": \"116.48074005043\", \"name \": \"this is firest location message\" } ",    
   "Timestamp ": 1662104191973,        
   "Name": "jack"
   },
   {    
   "MessageId": "1000000000000010",    
   "From": "861388888****",        
   "DisplayName":"Mr Wang",    
   "To": "861378168****",    
   "Type": "LOCATION",    
   "Message": "{\"address \": \"changsha yuelu street \", \"latitude \": \"39.999137107913\", \"longitude \": \"116.48074005043\", \"name \": \"this is firest location message\" } ",    
   "Timestamp ": 1662104191973,        
   "Name": "Jone"
   }
]

Request parameters

Parameter

Type

Required

Description

MessageId

String

Yes

The message ID.

From

String

Yes

The phone number of the message sender.

To

String

Yes

The phone number of the message receiver.

Timestamp

Long

Yes

The timestamp is a Unix timestamp in milliseconds.

DisplayName

String

Yes

The display name of the message sender.

Type

String

Yes

The type of the media resources that are included in the message. Valid values:

  • TEXT

  • LOCATION

  • DOCUMENT

  • VIDEO

  • AUDIO

  • REPLY

  • IMAGE

  • CONTACTS

Message

String

Yes

The content of the message.

  • If Type is set to TEXT, the message content is text.

  • If Type is set to LOCATION, Message specifies a location. For more information, see the table named Parameters that specify a location in the following section.

  • If Type is set to VIDEO, Message specifies a video file that is included in the message. For more information, see the table named Parameters that specify a video file in the following section.

  • If Type is set to AUDIO, Message specifies an audio file that is included in the message. For more information, see the table named Parameters that specify an audio file in the following section.

  • If Type is set to DOCUMENT, Message specifies a document that is included in the message. For more information, see the table named Parameters that specify a document in the following section.

  • If Type is set to REPLY, Message specifies a reply button that is included in the message. For more information, see the table named Parameters that specify a reply button in the following section.

  • If Type is set to IMAGE, Message specifies an image that is included in the message. For more information, see the table named Parameters that specify an image in the following section.

Name

String

Yes

The name of the end user.

Parameters that specify a location

Parameter

Type

Required

Description

address

String

Yes

The address of the location.

latitude

String

Yes

The latitude of the location.

longitude

String

Yes

The longitude of the location.

name

String

Yes

The description of the location.

Parameters that specify a video file

Parameter

Type

Required

Description

name

String

Yes

The description of the video file.

id

String

Yes

The ID of the video file.

mimeType

String

Yes

Fixed value: ogg.

Note

If the codecs parameter is set to opus, this parameter is optional.

url

String

Yes

The URL of the video file.

Note

The URL is valid for 7 days.

Parameters that specify an audio file

Parameter

Type

Required

Description

name

String

Yes

The description of the audio file.

id

String

Yes

The ID of the audio file.

mimeType

String

Yes

Fixed value: audio.

Note

If the codecs parameter is set to opus, this parameter is optional.

url

String

Yes

The URL of the audio file.

Note

The URL is valid for 7 days.

Parameters that specify an image

Parameter

Type

Required

Description

caption

String

No

The description of the image.

id

String

Yes

The image ID.

mimeType

String

Yes

The type of the image.

url

String

Yes

The URL of the image.

Note

The URL is valid for 7 days.

Parameters that specify a document

Parameter

Type

Required

Description

name

String

Yes

The description of the document.

id

String

Yes

The document ID.

filename

String

Yes

The name of the document.

mimeType

String

Yes

Fixed value: application/pdf.

url

String

Yes

The URL of the document.

Note

The URL is valid for 7 days.

Parameters that specify a reply button

Parameter

Type

Required

Description

text

String

Yes

The name of the reply button that the receiver can click.

payload

String

Yes

The payload of the reply message that is sent after the receiver clicks the reply button.

Response

If a message receipt is pushed to your HTTP server, the HTTP status code must be 200 and the response must be in the following format. Otherwise, the system tries to push the message receipt again.

Sample response

{
  "code" : 0,
  "msg" : "success"
}

Response parameters

Parameter

Type

Required

Description

code

Number

Yes

The response code.

msg

String

No

The description of the response code.

Retries

After the system fails to push a message receipt, it tries to push the message receipt again 1 minute later. If this retry fails, the system performs a second retry 5 minutes later. If the system fails to push a message receipt for three consecutive times, it will stop pushing the message receipt.