Our documentation is changing, please click here to enjoy it!

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This API route allows you to send a new message to targets. This new message won't be visible on the Accengage interface but will be linked to an existing one (the "parent" message).

Operations

POST

/sendInstantMessage.php

ParameterModel
body

 

1) Sending on only one application (one partner)

Code Block
titleData (send on 1 application)
languagejs
{
  sendInstantMessage: {
    user: User
    partner: Partner
    parentMessageId: String, mandatory if `parentMessageExternalId` is not set
    parentMessageExternalId: String, mandatory if `parentMessageId` is not set
    message: Message
    targets: [Target]
  }
} 

2) Sending on multi applications (several partners)

Code Block
titleData (send on multi applications)
languagejs
{
  sendInstantMessage: {
    user: User
    messages: Messages
    targets: [Target]
  }
} 
Code Block
titleMessages
languagejs
{
  partner: Partner
  parentMessageId: String, mandatory if `parentMessageExternalId` is not set
  parentMessageExternalId: String, mandatory if `parentMessageId` is not set
  message: Message
} 

 


 

Code Block
titleMessage
languagejs
{
  subject: String, optional
  text: String, optional
  customizedTitle: String, optional (1)
  longText: String, optional (1)
  bigPicture: String, optional (1)(3)
  icon: String, optional (1)(3)
  sound: String in ["None", "default", "custom"], optional
  language: String, optional
  soundName: String, optional
  badge: String, optional (2) (Only for Apple applications: To increment the badge, put a ‘+’ before the
		value of the badge)
  actionButtonLabel: String, optional
  richPushUrl: String, optional
  richPushOpening: String, optional
  popup: Boolean or Popup, optional (1)
  collapseKey: String, optional
  contentAvailable: boolean, default false, only for iOS
  customParams: [CustomParam], optional
  data: Content, optional
  interactiveButtons: InteractiveButtons, optional
  aps: Aps, optional (5)
} 

 


 

Code Block
titlePopup
languagejs
{
  okButtonLabel: String, optional
  cancelButtonLabel: String, optional
} 

 


 

Code Block
titleTarget
languagejs
{
  [criterion]: String or Criterion, optional, "=" will be used if String
  segmentId: String (4)
  staticListId: String(4)
  staticListExternalId (4)
  data: Content, optional
  aps: Aps, optional (5)
} 

 


 

Code Block
titleCriterion
languagejs
{
  Operator: String in ["=", "!=", "<", "<=", ">", ">="]
  Value: String
}

 


 

Code Block
titleContent
languagejs
{
  [template_name]: String, defined in the message text as ${template_name}
  value: String
} 

 


 

Code Block
titleAps
languagejs
{
  alert: String or Dictionary (5)
  sound: String, optional
  badge: Integer, optional
}

 


 

Code Block
titleInteractiveButtons
languagejs
{
  template: String, mandatory for iOS, optional for Android
  buttons: [Button], optional
} 

The value of the template can be found in the category on the interface or here for the Accengage's templates.


 

Code Block
titleButtons
languagejs
{
  id: String, index of the button in the template
  action: String, optional
  url: String, optional
  title: String, optional, only for Android
  icon: String, optional, only for Android
  destructive: Boolean, optional, only for Android, default true
  customParams: [CustomParam], optional
} 

 


 

Code Block
titleCustomParam
languagejs
{
  key: String
  value: String
}

 

(1) Only available for Android push messages

(2) Only available for iOS push messages

(3) The name of the image must be provided by the uploadImage API

(4) Only available when targeting one application (not for multi-applications)

(5) Refer to the Apple documentation : https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html

 

Response
body
Code Block
languagejs
{
  returnCode: String
  returnLabel: String
}
Return code
returnCodeDescription

0

Instant Message has been sent

1A database error occured
2No sendInstantMessage
3No or bad user
4No or bad partner
5No or bad message
6Bad custom params
9Bad targets
10No parent message ID
11Message limit exceeded
13Field unknown
14Target max number exceeded
15Template cannot be replaced
16No or bad appId
17The selected language does not exist

22

Invalid certificate
23No or bad template for buttons
24Nor or bad button id
25Bad custom params for buttons

If the message has been sent (returnCode: 0) in the case of multiple partners, you will only get the

messageId of the last message that you have provided in the Messages array.

The targets array contains all target definition for the message(s). This array can contain up to 100 entries.

One target object can contain multiple criteria, so a device will be targeted if all the criteria match the device properties. In the example below, a device will only be targeted if its language property is set to "en" AND the user opened the application more than once.

 

If the actions of the buttons are directly set in your request, their value must be one of the following: browser, email, phone, store, sms, webView, urlSheme or close.

 

The message text can contain template macros. These templates will be replaced with, in order:

  • values set in API target data object
  • values set in API message data object
  • values set in the devices database

If no value is found, an error is triggered.

Examples

RequestBodyDescription

POST URL

Code Block
titleExemple with one application
languagejs
{  
  "sendInstantMessage":{  
    "user":{  
      "login":"login@login.com",
      "password":"password"
    },
    "partner":{  
      "id":"my_partner_id"
    },
    "parentMessageId":"1",
    "message":{  
      "subject":"Flight canceled",
      "text":"Hi ${first_name}, the flight number ${flightref} is canceled",
      "sound":"custom",
      "soundName":"test.wav",
      "actionButtonLabel":"Ok",
      "richPushUrl":"http://www.google.com",
      "richPushOpening":"webview",
      "customParams":[  
        {  
          "key":"testKey",
          "value":"testValue"
        },
        {  
          "key":"testKey2",
          "value":"testValue2"
        }
      ],
      "data":{  
        "flightref":"EY5138"
      },
	  "aps":{
		"alert":"Hello Sir, the flight number ${flightref} is canceled",
		"badge":0
	  }
    },
    "targets":[  
      {  
        "memberId":"765c8",
        "data":{  
          "first_name":"Patrick"
        },
		"aps":{
		  "alert":{
			"body":"Hello ${first_name}, your flight has been canceled",
			"action-loc-key":"OK, thank you!"
		  },
		  "sound": "sound.wav",
		  "badge":2
		}
      },
      {  
        "language":{  
          "operator":"=",
          "value":"en"
        },
        "opencount":{  
          "operator":">",
          "value":"1"
        },
        "data":{  
          "first_name":"John"
        }
      }
    ]
  }
}
Code Block
titleExemple with multi applications
languagejs
{
"sendInstantMessage":{
  "user":{
    "login": "login@login.com",
    "password": "password"
  },
  "messages": [{
    "partner": {
       "id": "my_first_partner_id"
    },
    "parentMessageId": "1",
    "message": {
      "subject": "Hello",
      "text": "You are receiving a message"
    }
  },      
  {
    "partner": {
      "id": "my_second_partner_id"
    },
    "parentMessageId": "2",
    "message": {
      "subject": "Hello",
      "text": "You are receiving a message"
    }
  }],
  "targets": [{
    "language": {
      "operator":"=",
      "value":"en"
    },
    "opencount":{
      "operator":">",
      "value":"1"
    }
  ]}
  }
}
Code Block
titleExemple with interactive buttons
languagejs
{  
  "sendInstantMessage":{  
    "user":{  
      "login":"login@login.com",
      "password":"password"
    },
    "partner":{  
      "id":"my_partner_id"
    },
    "parentMessageId":"1",
    "message":{  
      "subject":"Flight canceled",
      "text":"Hi ${first_name}, the flight number ${flightref} is canceled",
      "sound":"custom",
      "soundName":"test.wav",
      "actionButtonLabel":"Ok",
      "richPushUrl":"http://www.google.com",
      "richPushOpening":"webview",
      "interactiveButtons" : {        
	    "template": "category_name",
        "buttons": [
          {
            "id": 1,
            "title": "Confirm",
            "url": "http://google.fr",
            "icon": "ic_action_search",
            "action": "browser",
            "destructive": false,
            "customParams": [
              {
                "key": "testKey",
                "value": "testValue"
              },
              {
                "key": "testKey2",
                "value": "testValue2"
              }
            ]
          },
          {
            "id": 2,
            "url": "http://mobilecrm.accengage.com",
            "icon": "action_settings_light",
            "action": "webView"
          }
       ]
      },
      "customParams":[  
        {  
          "key":"testKey",
          "value":"testValue"
        },
        {  
          "key":"testKey2",
          "value":"testValue2"
        }
      ],
      "data":{  
        "flightref":"EY5138"
      },
	  "aps":{
		"alert":"Hello Sir, the flight number ${flightref} is canceled",
		"badge":0
	  }
    },
    "targets":[  
      {  
        "memberId":"765c8",
        "data":{  
          "first_name":"Patrick"
        },
		"aps":{
		  "alert":{
			"body":"Hello ${first_name}, your flight has been canceled",
			"action-loc-key":"OK, thank you!"
		  },
		  "sound": "sound.wav",
		  "badge":2
		}
      },
      {  
        "language":{  
          "operator":"=",
          "value":"en"
        },
        "opencount":{  
          "operator":">",
          "value":"1"
        },
        "data":{  
          "first_name":"John"
        }
      }
    ]
  }
}
Sends an instant message