Send message

This method allows you to send a single message.

Resource

https://api.infobip.com/omnichat/1/applications/{applicationKey}/integrations/{integrationType}/message

Parameters

Property name Type Description
applicationKey* string application key  
integrationType* string application key  
to* string User key.
message* object Message object.

Request Example

					POST /omnichat/1/applications/0F3C3F29829FAB88714BA205BEC6D28F/integrations/FACEBOOK/message HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json

{
  "to":"37512FEC78DBC1895567B09AE6D9439328C12E83BC83D449BC4A9F32F1AE3C3A",
  "message": {
    "type":"TEXT",
    "text":"Hello, World!"
  }
}
					
				

Response

					{
  "to": "37512FEC78DBC1895567B09AE6D9439328C12E83BC83D449BC4A9F32F1AE3C3A",
  "messageCount": 1,
  "messageId": "1215f543ab19-345f-adbd-12ad31451ed25f35",
  "status": {
    "groupId": 1,
    "groupName": "PENDING",
    "id": 7,
    "name": "PENDING_ENROUTE",
    "description": "Message sent to next instance"
  }
}
					
				
					{
  "requestError": {
    "serviceException": {
      "messageId": "BAD_REQUEST",
      "text": "Bad request"
    }
  }
}
					
				
					{
  "requestError": {
    "serviceException": {
      "messageId": "UNAUTHORIZED",
      "text": "Invalid login details"
    }
  }
}
					
				

Response format

If successful, the response header HTTP status code will be 200 OK and the message will be sent. If you try to send the message without authorization, you will receive a 401 Unauthorized error. If the request is incorrectly formatted, the HTTP status code will be 400 Bad Request.

Response

Parameter Type Description
to String User key.
status Status Indicates whether the message is sent successfully, not sent, delivered, not delivered, waiting for delivery or any other possible status.
messageCount int The number of sent message segments.
messageId String The ID that uniquely identifies the sent message.

Status

Parameter Type Description
groupId int Status group ID.
groupName String Status group name.
id int Status ID.
name String Status name.
description String Human-readable description of the status.
action String Action that should be taken to eliminate the error.

Request Format

Property name Type Required Description
to String Yes User key.
message Object Yes Message object.

Message Object

Supported message objects are:

Text Message

Type TEXT is used when sending a text message.

Property name Type Required Description
type String Yes Constant value - TEXT.
text String Yes Text of the message.

 

Request example:

POST /omnichat/:version/applications/0F3C3F29829FAB88714BA205BEC6D28F/integrations/FACEBOOK/message HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json

{
  "to":"37512FEC78DBC1895567B09AE6D9439328C12E83BC83D449BC4A9F32F1AE3C3A",
  "message": {
    "type":"TEXT",
    "text":"Hello, World!"
  }
}	
  

Image Message

Besides the text message, image messages can also be sent over API. Before sending the message, you will need to upload your image to a publicly accessible server and supply the url of the file.

Property name Type Required Description
type String Yes Constant value - IMAGE.
text String Yes Text of the message.
url String Yes Image url.

 

Request example:

POST /omnichat/:version/applications/0F3C3F29829FAB88714BA205BEC6D28F/integrations/FACEBOOK/message HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json

{
  "to":"37512FEC78DBC1895567B09AE6D9439328C12E83BC83D449BC4A9F32F1AE3C3A",
  "message": {
    "type":"IMAGE",
    "text":"Hello, World!",
    "url":"https://petersapparel.com/img/shirt.png"
  }
}	
  

Buttons Message

A Buttons message contains a text shown to the user, as well as some predefined options that the user may select by tapping them.

Property name Type Required Description
type String Yes Constant value - BUTTONS.
text String Yes Text of the message.
buttons Array of buttons Yes Button objects. Max 3.

Postback button

Postback button causes a callback event to be fired when the user presses a button.

Property name Type Required Description
type String Yes Constant value - POSTBACK.
text String Optional Text of the button (as displayed to the user).
payload String Yes Value to be posted back when the user presses the button.

URL button

Property name Type Required Description
type String Yes Constant value - URL.
text String Optional Text of the button (as displayed to the user).
url String Yes URL that should be opened when user presses the button.

 

Request example:

POST /omnichat/:version/applications/0F3C3F29829FAB88714BA205BEC6D28F/integrations/FACEBOOK/message HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json

{
  "to":"37512FEC78DBC1895567B09AE6D9439328C12E83BC83D449BC4A9F32F1AE3C3A",
  "message": {
    "type":"BUTTONS",
    "text":"Do you want to subscribe to our service X?",
    "buttons": [
      {
        "type":"POSTBACK",
        "text":"Yes",
        "payload":"userId:abc123"
      },
      {
      	"type":"URL",
        "text":"Learn more",
        "url":"http://company.com/about-service-x"
      }
    ]
  }
}