Receive chat message

You can receive messages sent by your mobile application users (Sending messages using iOS SDK, Sending messages using Android SDK) in your backend service.

To achieve that Push Configuration and Action setup must be completed. Configuration is a logical container for Actions. You can choose a method of incoming message delivery through the Action setup, but before, Configuration must be created since the Action can only exist inside of the Configuration container.

Push Configuration Action Scheme

1) Create Push Configuration using your application code, copy configuration key from the response, it will be used in Push Action creation.

Request example:

POST /push/1/applications/{applicationCode}/configurations/ HTTP/1.1
Host: api.infobip.com
Authorization: Basic your-creds-base64	
  

Response example:

{
    "key": "CB0F6CEC031D81116AB72720C1765A9D"
}	
  

2) Set up a unique web address on your own web server able to receive a POST request.

3) Create Push Action for HTTP forward method using your application code. Every message from the users of your application will be forwarded to the URL provided as "forwardUrl" parameter.

Request example:

POST /push/1/applications/{applicationCode}/configurations/{configurationKey}/actions/ HTTP/1.1
Host: api.infobip.com
Content-Type: application/json
Authorization: Basic your-creds-base64
{
    "type": "HTTP_FORWARD",
    "forwardUrl": "http://example.com"
}	
  

Response example:

{
    "key": "actionKey",
    "type": "HTTP_FORWARD",
    "forwardUrl": "http://example.com"
}	
  

You may need to whitelist IPs that we use to deliver messages.

Example of forwarded message:


{
    "results": [{
        "from": "3D7F797B-8841-4A95-9AAB-D529E94D6964",               
        "to": "233623e3c860b49ec69a464834343481-8bj4el4a-256d-23fd-56ad-b5bc3d568b53",         
        "text": "Are you ready?",
        "receivedAt": "2017-11-21T12:47:21.211+0000",
        "customPayload": {                
            "isChat": true,
            "sender": "3D7F797B-8841-4A95-9AAB-D529E94D6964",
            "senderFirstName": "Boris",
            "senderLastName": "Yurinov",
            "senderMiddleName": "Blade",
            "senderEmail": "boris.blade@email.com",
            "senderGsm": "385989000000",
            "senderData": "{\"bladeType\": \"sharp\"}"
        }
    }],
    "messageCount": 1,
    "pendingMessageCount": 0
}