Skip to main content

Trigger App Message

Trigger App Message is a message type that allows you to send a command to your main application. The text you forward in this message template is displayed on both the notification and dialog list screens. When the mobile user clicks on this notification or this message from the dialog list, the command and data you pass in the message to your main application will be triggered as an event.

This message type allows you to initiate an action remotely from the device of the relevant mobile user. For example, you can open a confirmation screen with this message you sent to your customer. The command and data fields in this message are completely parametric. This command and data information must be mutually determined between your mobile application and the application sending the message, and codes that will initiate the necessary action in the mobile client must be developed according to this information.

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": "70023"
},
"message": {
"text" :"Please click this message to approve your transaction",
"messageId":"messageId-5566112",
"trigger" : {
"command" : "ApproveTransaction",
"data" : "{custNo:2337368}"
},
"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#

The content of the Generic Template message can be given in the attachment property instead of text propeperty to the api.

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
triggerObjectattachment object that has content of the message.Yes
quickRepliesArray<quickReply>It should be set as empty array. ("quickReplies" : [])Yes
quickRepliesV2Array<quickReplyV2>It should be set as empty array. ("quickRepliesV2" : [])Yes

trigger#

trigger is an object that contains commands and data parameters that tell you what action to take in your main application. The commands and data transmitted within the trigger object are transmitted to the main application in an event

PropertyTypeDescriptionMandatory
commandStringIt is the command information you want to pass to your main application.Yes
dataStringYou can use this field to transmit the data related to the command along with the command to your main application. You can use this field to transmit the data related to this command along with the command to your main application. Even if you are not going to send any data, it should be given as empty string.Yes

Response#

Successful API requests return the json object with the answer code http-2XX.

Sample response

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