Document Message
Document Message type allows you to send documents, images, video or audio files from your applications.
This api will get base64 encoded string of your file nd it will send it to your Diyalog clients. Platfrom will permit only smaller than 5MB size of files. Otherwise you will receive error from the api.
This api is also asynchronous and when a api call received the system only check api token, recepient, file data, file size and than return success as response. After that api will try to send the document to you clients asynchronously. If you want to sure the file is sent or not, you should check the webhook events that feed to your webhook api by Diyalog.
#
Request URI#
Example Request#
Request Detailsrecipient#
You can pass the user information you want to send the message to api in the recipient object.
Property | Type | Description | Mandatory |
---|---|---|---|
appCustomerId | String | Customer id in your system | Optional |
appStaffId | String | Your staff id. | Optional |
id | String | Unique DLG user id. | Optional |
You can pass the the user information that will receive your message with this object. Your request should only have one of the properties that appCustomerId, appStaffId or id.
There are two unique id for a single user in the DLG platform One of them is DLG user id. This id is created randomly when user registering to the system. Besides of this id, according to the user type, one of the customer id or staff id are stored for the user in DLG.
As a result, you can use one of the customer id or staff id and DLG id in order to send message.
If you know the DLG user id, you can use it for customor or staff.
Using customer id and staff id is more applicable than using DLG user id. Because if you want to use DLG id, you should store all DLG user ids in your system.
message#
Property | Type | Description | Mandatory |
---|---|---|---|
messageId | String | This is a unique id of your message. You should create it in your system and send it to api. If you don't create and sent it to api DLG will create it for you and send it to you in the response of your request. DLG platfrom will feed the events of the messages to your system by this id. You can use it to differenciate events by this id. Therefore, this id is important for following all events of your message by your system. | Optional |
document | Object | document object that has content of the document. | Yes |
quickReplies | Array<quickReply> | It should be set as empty array. ("quickReplies" : []) | Yes |
quickRepliesV2 | Array<quickReplyV2> | It should be set as empty array. ("quickRepliesV2" : []) | Yes |
document#
document object contains data of your document that you want to sent to your clients.
Property | Type | Description | Mandatory |
---|---|---|---|
fileName | String | It is the filename of the document with file extention. | Yes |
fileData | String | Base64 encoded string of bytes of the file. | Yes |
mimeType | String | This is the type of your file. You can add extention of your file. | No |
photo | Object | If you are sending an image file and you want to show thumbnail in clients, you can provide photo object that has detail of the image file. If you are sending an image and you give this object, Diyalog will automatically create a thumbnail of the file and make this thumbnail appear in the messaging screens even if the user does not open the image in the client. | No |
video | Object | If you are sendinding a video file, you can provide video object that has some detail of the video file. If provide this object, Diyalog will show this file as video message format other than standart document. | No |
voice | Object | If you are sendinding a voice message file, you can provide voice object that has some detail of the voice file. If provide this object, Diyalog will show this file as voice message format other than standart document. | No |
In order for the system to work properly, you must give only one of the photo, video and voice objects as a parameter. Otherwise, you may send an incorrect message. If you do not provide any of these objects, the system will transmit the document as a standard document message.
photo#
photo object contains width and height information of your image
Property | Type | Description | Mandatory |
---|---|---|---|
width | Integer | Width of your image. | Yes |
height | Integer | Height of your image. | Yes |
#
Example Requestvideo#
video object contains width, height and duration information of your video
Property | Type | Description | Mandatory |
---|---|---|---|
width | Integer | Width of your video. | Yes |
height | Integer | Height of your video. | Yes |
duration | Integer | Duration in seconds of your video. | Yes |
#
Example Requestvoice#
voice object contains duration information of your video
Property | Type | Description | Mandatory |
---|---|---|---|
duration | Integer | Duration in seconds of your voice message. | Yes |
#
Example Request#
ResponseSuccessful API requests return the json object with the answer code http-2XX.
Sample response
#
Error ResponsesHttp Status Code | Error Message | Description |
---|---|---|
400 | The request content was malformed: .... | Requset is invalid Malformed api request. |
400 | Exceeded max file size of 5MB | Document is too big to send. It should be smaller than 5MB |
400 | File data bytes not valid | Base 64 encoded file bytes cannot be parsed. File data is not valid. |
400 | File data bytes is empty | FileData is empty. You should provide valid fileData to the api |
400 | File as photo cannot be parsed due to it is not a image file. | Document sent as photo is not have valid image file. |
503 | You may be using wrong token. | Your Diyalog webbot token is not validated. Check your token |
500 | Not delivered due to recepient not found. | Message cannot be sent due to receipient is not found in Diyalog |
500 | Sender bot is not alive. | Diyalog Internal server error. WDiyalog webbot is not active in the server to send message. |