Text Message

You can send text messages to your user.

Request URI

https://<DIYALOG-SERVER-API-ENDPOINT>/v1/bots/sendmessage/<YOUR-BOT-ACCESS-TOKEN>

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
"recipient": {
"appCustomerId": "1231232"
},
"message": {
"messageId": "messageId-1",
"text" : "Hello world !",
"quickReplies" : [],
"quickRepliesV2" : []
}
}' "https://<DIYALOG-SERVER-API-ENDPOINT>/v1/bots/sendmessage/<YOUR-BOT-ACCESS-TOKEN>"

Request Details

recipient

You can pass the user information you want to send the message to api in the recipient object.

PropertyTypeDescriptionMandatory
appCustomerIdStringCustomer id in your systemOptional
appStaffIdStringYour staff id.Optional
idStringUnique 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

PropertyTypeDescriptionMandatory
messageIdStringThis 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
textStringText that will send to your user.Yes
quickRepliesArray<quickReply>This property is not used in the text message. It should be set as "quickReplies" : []Yes
quickRepliesV2Array<quickReplyV2>This property is not used in the text message. It should be set as "quickRepliesV2" : []Yes

Response

Successful API requests return the json object with the answer code http-2XX.
Response JSON object will have recipient id and message id properties. Recipient id will be the DLG user id. And message id will be the message id that is given with the request. If the request has not have any message id, DLG will create a message id and add it to response.

Response Details

PropertyTypeDescription
recipient_idStringDLG user id.
message_idStringIt is the id of the message sent to the user. If you have given a messageId in the request, this id will be sent back to you in this field. If you have not provided an id, the unique id created in the DLG system returns from this field.

Sample response

{
"recipient_id": "2074022437",
"message_id": "-7523925115459309081"
}