Skip to content

Notification Service – Samples

Sending email notification with simple content

Below are the steps required to send email with simple content.

  • Use API endpoint - POST /api/notification/v3/publisher/messages

Multiple email recipients can be provided as semicolon-separated in the 'recipientTo' field.

Sample Request payload:

1
2
3
4
5
6
7
8
9
{
    "body":
        {
            "message":"Email message content"
        },
    "recipientsTo":"xxxxxxxx.xxxxxxxx@siemens.com;yyyyyyyyy.yyyyyy@mindsphere.io",
    "from":"sender-name",
    "subject":"Mail subject"
}

Sending email notification with template

To send emails using templates, call the APIs below in the order listed.

Creating recipient with email details

  • Use API Endpoint - POST /api/notification/v3/recipient/

For providing the valid input for "addresstypeid" key, "/recipient/addresstype" API can be referred.

Sample Request:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "recipientname" : "XXXXXXXX XXXXXXXX",
  "recipientdetail" : [ {
    "address" : "xxxxxx.xxxxxx@siemens.com",        
    "addresstypeid" : 2
  },
  {
    "address" : "personalmail@gmail.com",
    "addresstypeid" : 1
  } ]
}

Sample Response:

1
806
The generated recipient ID will be sent in response. This information needs to be stored as reference for further API calls.

Creating a template with content of the message to be sent

  • Use API Endpoint - POST /api/notification/v3/template/

Please follow the API guidelines for this endpoint for detailed information regarding the placeholder information. For providing the valid input for "commChannelId" key, "/communicationchannel/" API can be referred.

Sample response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "templatesetId": 111,           
    "templatesetName": "TestTemplateForEmail",
    "templateList": [
        {
            "templateId": 412,      
            "commChannelId": 1,
            "commChannelName": "Email"
        }
    ]
}

The values of "templatesetId" and "templateId" needs to be stored as reference for further API calls.

Creating category using the template and recipients

  • Use API Endpoint - POST /api/notification/v3/communicationcategories/

Sample Request:

Here, the information from the response of above API calls like recipient ID, templatesetId and templateId will be sent in request.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
    "msgCategoryName": "category Name",
    "subject": "Any subject",
    "priority":1,
    "from":"sender-name",
    "recipients":[
        {
            "recipientId":806,
            "position":"TO"
        }
    ],
    "templates":[
        {
            "templateId":412,
            "templatesetId":111,
            "commChannelName":"Email"
        }
    ]   
} 

Sample Response:

1
    642
The value of generated category ID will be sent in response. This information needs to be stored as reference for further API call.

Triggering the notification

  • Use API endpoint - POST /api/notification/v3/publisher/messages

The placeholder params, which were provided in the uploaded template, should be provided in request as key and the respective values of the params as their respective values. Apart from the recipients which were binded to the category, while creating category, other email recipients can be provided as semicolon-separated in the 'recipientTo' field. Also, the categoryId created in the previous API call has to be provided in the request. Please refer to the sample request.

1
2
3
4
5
6
7
8
{
  "body" : {
    "placeholderkey1" : "placeholder value1",
    "placeholderkey2" : "placeholder value2",
        },
    "recipientsTo" : "xxxxxxx.xxxxxx@siemens.com",
    "messageCategoryId" :642
}

Sending push notification with template

Notification services provides the functionality of sending push notifications to mobile devices. For sending Push notifications, below are the API's which needs to be called in the mentioned sequence.

Creating recipient with push notification details

  • Use API Endpoint - POST /api/notification/v3/recipient/

For providing the valid input for "addresstypeid" key, "/recipient/addresstype" API can be referred. The information required in request as Push parameters are defined below:

  • serverApiKey
    - It is a key saved on the app server that gives the app server authorized access to Google services. This is unique to every application.
  • appId
    - An ID issued by the GCM connection servers to the client app that allows it to receive messages. This is specific to every device and the application installed.
  • applicationName
    - Name of the application for sending the Notifications.

Sample Request:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "recipientname" : "PushNotificationTest",
  "recipientdetail" : [{
    "address" : {
            "appId":"XXXXXXXXXXXXXXXXXXXXX",
            "serverApiKey":"XXXXXXXXXXXXXXXXX",
            "applicationName":"App Name 1"

    },
    "addresstypeid" : 7
  }]
}

Sample Response:

1
806

The generated recipient ID will be sent in response. This information needs to be stored as reference for further API calls.

Creating a template with content of a push notification message

  • Use API Endpoint - POST /api/notification/v3/template/

Please follow the API guidelines for this endpoint for detailed information reagrding the placeholder information. For providing the valid input for "commChannelId" key, "/communicationchannel/" API can be referred.

Sample response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "templatesetId": 436,           
    "templatesetName": "TestTemplateForPushNotification12",
    "templateList": [
        {
            "templateId": 468,      
            "commChannelId": 3,
            "commChannelName": "Push Notification"
        }
    ]
}

The values of "templatesetId" and "templateId" needs to be stored as reference for further API calls.

Creating catetgory using the template and recipients

  • Use API Endpoint - POST /api/notification/v3/communicationcategories/

Sample Request:

Here, the information from the response of above API calls like recipient ID, templatesetId and templateId will be sent in request.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
    "msgCategoryName": "category Name",
    "subject": "Any subject",
    "priority":1,
    "from":"sender-name",
    "recipients":[
        {
            "recipientId":806,
            "position":"TO"
        }
    ]   ,
    "templates":[
        {
            "templateId":468,
            "templatesetId":436,
            "commChannelName":"Push Notification"
        }
    ]   
} 

Sample Response:

1
    642

The value of generated category ID will be sent in response. This information needs to be stored as reference for further API calls.

Triggering the notification

  • Use API endpoint - POST /api/notification/v3/publisher/messages

The placeholder params, which were provided in the uploaded template, should be provided in request as key and the respective values of the params as their respective values. Also, the categoryId created in the previous API call has to be provided in the request. Please refer to the sample request.

Sample Request:

1
2
3
4
5
6
7
8
{
    "body" : 
    {
        "placeholderkey1" : "placeholder value1",
        "placeholderkey2" : "placeholder value2",
    },
    "messageCategoryId":642
}

Notification API specifications can be further referred for details.

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.