Line Notification Service Example
In the following examples, we’ll show you how to configure the Line Notification Service-SMS failover scenario and send your first messages.
The messages will first be sent over Line Notification Service communication channel. If the messages are rejected on Line (for example, the user doesn’t have Line installed), the messages will be sent using the SMS communication channel. For each communication channel, a specific validity period can be set.
There are three easy steps to follow:
Line Notification Service - SMS OMNI process
1. Create OMNI scenario
The first step is to create an OMNI scenario. In the OMNI scenario configuration, you need to define the OMNI steps which will be sequentially executed. The key parameters are the channel and from, respectively identifying the communication channels and senders for each communication channel.
POST /omni/1/scenarios HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
"name":"My LINE-SMS scenario",
"flow": [
{
"from":"InfoLine",
"channel": "LINE"
},
{
"from": "InfoSMS",
"channel": "SMS"
}
],
"default": true
}
Response format
If successful, the response header HTTP status code will be 200 OK and the scenario will be created, as shown in the example below.
If you try to create the scenario without authorization, you will receive a 401 Unauthorized error.
{
"key": "CC9F01A5DC7BEE2C2B829D203482A654",
"name":"My LINE-SMS scenario",
"flow": [
{
"from": "InfoLine",
"channel": "LINE"
},
{
"from": "InfoSMS",
"channel": "SMS"
}
],
"default": true
}
The key parameter needs to be stored as it will be used when sending the message.
Info
You can find more information about creating an OMNI scenario at: Scenario:// Create.
2. Send OMNI message
Once you’ve created an OMNI scenario (identified by the key parameter) as described in the previous chapter, you are ready to send your OMNI messages through defined Line and SMS communication channels. First, the Line message will be sent to the defined phoneNumber. If for some reason, the message is rejected on the Line or the end user doesn’t have the Line application installed, the message will be sent using the SMS communication channel.
For sending OMNI messages, you can use the advanced API method. Detailed descriptions about the advanced API method can be found here: OMNI:// Send an advanced message.
The parameters that should be set are the scenario key and phoneNumber (JSON object where the keys are names of parameters in the template) text for the SMS failover as shown below. Field isPromotional is not mandatory and by default is set to false.
Text message
POST /omni/1/advanced HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
"scenarioKey": "CC9F01A5DC7BEE2C2B829D203482A654",
"destinations": [{
"to": {
"phoneNumber": "41793026727"
}
}],
"line": {
"type": "TEXT",
"text": "This Line message will be delivered to Line application on the user device."
},
"sms": {
"text": "This text will be received if Line communication channel message is not delivered."
}
}
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.
HTTP/1.1 200 OK
Content-Type: application/json
{
"messages": [{
"to": {
"phoneNumber": "41793026731"
},
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 7,
"name": "PENDING_ENROUTE",
"description": "Message sent to next instance"
},
"messageId": "50c24400-124f-4678-9f4b-309e994a4deb"
}]
}
3. Get Delivery Reports
Once you’ve successfully sent your message using the advanced API method you can check the status of sent messages using the OMNI reports method.
The simplest way is to use the method without any query parameters. In that case, the response will contain all messages sent to a specific account.
GET /omni/1/reports HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept: application/json
The response will contain all messages, rejected and delivered, as shown in the example below.
{
"results": [{
"bulkId": "",
"price": {
"pricePerMessage": 0.000000,
"currency": "HRK"
},
"status": {
"id": 5,
"groupId": 3,
"groupName": "DELIVERED",
"name": "DELIVERED_TO_HANDSET",
"description": "Message delivered to handset"
},
"error": {
"id": 0,
"name": "NO_ERROR",
"description": "No Error",
"groupId": 0,
"groupName": "OK",
"permanent": false
},
"messageId": "1215f543ab19-345f-adbd-12ad31451ed25f35",
"doneAt": "2019-01-10T16:27:20.098+0000",
"messageCount": 1,
"sentAt": "2019-01-10T16:27:18.497+0000",
"to": "41793026727",
"channel": "LINE"
}]
}
Additional Examples
Send Line image message
If you would like to send Line image messages, please check the example provided below.
| Parameter | Type | Description |
| type | constant | IMAGE |
| url | string | Url of the image sent in the Line message. Max 1000 characters. |
| thumbnailUrl | string | Thumbnail of the image sent in the Line message. Max 1000 characters. |
Line image message
When sending Line image message, url and thumbnailUrl are mandatory fields!
Line image message request example:
POST /omni/1/advanced HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
"scenarioKey": "CC9F01A5DC7BEE2C2B829D203482A654",
"destinations": [{
"to": {
"phoneNumber": "41793026727"
}
}],
"line": {
"type": "IMAGE",
"url": "http://www.infobip.com/infobip-logo.png",
"thumbnailUrl": "http://www.infobip.com/infobip-logo.png"
},
"sms": {
"text": "This text will be received if Line communication channel message is not delivered."
}
}
Send Line Audio message
| Parameter | Type | Description |
| type | constant | AUDIO |
| url | string | Url of the audio record that will be sent in the Line message. Max 1000 characters. |
| duration | long | Duration of the audio file. |
Line Audio message
When sending Line audio message, url and duration are mandatory!
Line audio message request example:
{
"scenarioKey": "CC9F01A5DC7BEE2C2B829D203482A654",
"destinations": [{
"to": {
"phoneNumber": "41793026727"
}
}],
"line": {
"type": "AUDIO",
"url": "https://www.audioUrl.com",
"duration": 4000
},
"sms": {
"text": "This text will be received if Line communication channel message is not delivered."
}
}
Send Line Video message
If you would like to send Line video messages, please check the example provided below.
| Parameter | Type | Description |
| type | constant | VIDEO |
| url | string | Url of the video that will be sent in the Line message. Max 1000 characters. |
| thumbnailUrl | string | Thumbnail of the video that will be sent in Line message. Max 1000 characters. |
Line Video message
When sending Line video message, url and thumbnailUrl are mandatory!
Line Video message request example:
{
"scenarioKey": "CC9F01A5DC7BEE2C2B829D203482A654",
"destinations": [{
"to": {
"phoneNumber": "41793026727"
}
}],
"line": {
"type": "VIDEO",
"url": "https://www.videoUrl.com",
"thumbnailUrl": "https://www.thumbnailUrl.com"
},
"sms": {
"text": "This text will be received if Line communication channel message is not delivered."
}
}
Send Line Sticker message
If you would like to send Line sticker messages, please check the example provided below.
| Parameter | Type | Description |
| type | constant | STICKER |
| packageId | string | Package id of sticker that will be sent. |
| stickerId | string | Sticker id that will be sent. |
Line Sticker message
When sending Line sticker message, packageId and stickerId are mandatory! For information about stickers, see the Line official sticker list
Line sticker message request example:
POST /omni/1/advanced HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
"scenarioKey": "CC9F01A5DC7BEE2C2B829D203482A654",
"destinations": [{
"to": {
"phoneNumber": "41793026727"
}
}],
"line": {
"type": "STICKER",
"packageId": "1",
"stickerId": "1"
},
"sms": {
"text": "This text will be received if Line communication channel message is not delivered."
}
}