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)

{
  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)

{
  sendInstantMessage: {
    user: User
    messages: Messages
    targets: [Target]
  }
} 
{
  partner: Partner
  parentMessageId: String, mandatory if `parentMessageExternalId` is not set
  parentMessageExternalId: String, mandatory if `parentMessageId` is not set
  message: Message
} 

 


 

{
  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)
} 

 


 

{
  okButtonLabel: String, optional
  cancelButtonLabel: String, optional
} 

 


 

{
  [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)
} 

 


 

{
  Operator: String in ["=", "!=", "<", "<=", ">", ">="]
  Value: String
}

 


 

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

 


 

{
  alert: String or Dictionary (5)
  sound: String, optional
  badge: Integer, optional
}

 


 

{
  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.


 

{
  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
} 

 


 

{
  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
{
  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

{  
  "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"
        }
      }
    ]
  }
}
{
"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"
    }
  ]}
  }
}
{  
  "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