Create Message


Create common messages and alert messages on the Application Portal.

Prerequisites


  • The associated application has been acquired by the organization.

  • If this message is an alert about an asset, the asset or the parent node of the asset must have a tag value with “auth_unit: true”.

Request Format


POST https://{apigw-address}/app-portal-service/v2.2/message/produce

Request Parameters (Body)


Name

Mandatory/Optional

Data Type

Description

messages

Mandatory

MessageProduceDTO Struct

The message details.

MessageProduceDTO Struct


Name

Mandatory/Optional

Data Type

Description

messageId

Mandatory

String

The message ID.

type

Optional

Integer

The message type.

  • 0: common message

  • 1: alert message

orgId

Mandatory

String

The organization ID which the asset belongs to. How to get orgId >>

accessKey

Mandatory

String

The service account of the application. The application authenticates with accessKey to obtain the data that it is authorized to access. How to get accessKey>>

body

Optional

I18nString

Specify the message in its respective locale’s language. You must specify at least the default or en_US value. For more details on the structure and locales supported, see Internationalized name struct

color

Optional

Integer

The color to indicate the message severity. How to get message icon color>>

ring

Optional

Integer

The ringtone for the message. How to get message ringtones>>

tags

Optional

Map

Specify the tags in its respective locale’s language. Note: only the first 3 tags will be displayed. You must specify at least the default or en_US value. For more details on the structure and locales supported, see Internationalized name struct

produceTime

Mandatory

String

The time the message is produced. Format: “yyyy-MM-dd HH:mm:ss”

state

Optional

Integer

The state of the message.

  • 0 = resolved

  • 1 = not resolved

zoneOffset

Mandatory

String

The timezone, such as “+08:00”.

linkedAppId

Optional

String

The application ID associated with the alert message. (linkedAppId, linkedMenuCode, and linkedStates constitute the redirection URL, such as https://{app-service-address}/portal/60d110ff-f388-48f4-916b-9e637d4886af/alarmProcessing?state=site%253DeVKqg4zr, where, {App-service-address} is the service address that can display all alerts and “60d110ff-f388-48f4-916b-9e637d4886af” is the linkedAppId)

linkedMenuCode

Optional

String

The menu identifier within the application that is associated with the message. (linkedAppId, linkedMenuCode, and linkedStates constitute the redirection URL, such as https://{app-service-address}/portal/60d110ff-f388-48f4-916b-9e637d4886af/alarmProcessing?state=site%253DeVKqg4zr, where, {App-service-address} is the service address that can display all alerts and “alarmProcessing” is the linkedMenuCode)

linkedStates

Optional

String

URL state associated with the message. (linkedAppId, linkedMenuCode, and linkedStates constitute the redirection URL, such as https://{app-service-address}/portal/60d110ff-f388-48f4-916b-9e637d4886af/alarmProcessing?state=site%253DeVKqg4zr, where, {App-service-address} is the service address that can display all alerts and “site%253DeVKqg4zr” is the linkedStates)

feature

Optional

I18nString

Specify the description by the customer in its respective locale’s language. You must specify at least the default or en_US value. For more details on the structure and locales supported, see Internationalized name struct

assetId

Optional

String

The ID of the asset associated with the alert message. If the alert message is not related to an asset, there is no need to provide this.

authUnitId

Mandatory

String

The asset tagged as “auth_unit:true” in the asset tree of the EnOS. The value can either be “assetId” or the parent node of the “assetId”. It is the asset ID synchronized to the Application Portal to verify the permissions of an application.

For example, there are several solar panels under a solar power station. Each solar panel has its own asset ID: assetId1, assetId2, and so on. The asset tree of this solar power station on the EnOS is tagged with “auth_unit:true”. When the solar power station informaton is successfully synchronized to the Application Portal (the authUnitId is valid), if an organization has an application represented by the appId, the users who can view the solar power station in the Application Portal can receive the corresponding alert message. In this example, assetId is the ID of a solar panel and authUnitId is the solar power station ID.

callbackUrl

Mandatory

String

The complete URL of the Application Portal callback (supporting URL Encode) after clicking the corresponding button of ActionName in the message window. This callback is a “GET” request. For example: https://{app-service-address}/callback?appId=accessKey&messageId=messagett0q22w1299 or https%3a%2f%2f%7bapp-service-address%7d%2fcallback %3fappId%3daccessKey%26messageId%3dmessagett0q22w1299+, where {app-service-address} is the server address that receive and process the callback request.

actionName

Mandatory

I18nString

Specify the customized text on the button in the message window in its respective locale’s language. It is recommended to use two characters for Chinese and three characters for English, such as “确认” and “ACK”. If not provided, it will not be displayed. You must specify at least the default or en_US value. For more details on the structure and locales supported, see Internationalized name struct

Samples

Request Sample


url: https://{apigw-address}/app-portal-service/v2.2/message/produce

method: POST

requestBody:
{
  "messages": [
    {
      "zoneOffset": "+08:00",
      "linkedMenuCode": "menucode",
      "linkedAppId": "accessKey",
      "color": 1,
      "ring": 1,
      "messageId": "your_message_id",
      "produceTime": "2019-07-24 11:22:01",
      "body": {
        "default": "your_message",
        "en_US": "your_message_en",
        "zh_CN": "your_message_zh",
        "ja_JP": "",
        "es_ES": ""
      },
      "type": 1,
      "tags": [
        {
          "default": "Severe",
          "en_US": "Severe",
          "zh_CN": "严重",
          "ja_JP": "",
          "es_ES": ""
        },
        {
          "default": "Performance Alarm",
          "en_US": "Performance Alarm",
          "zh_CN": "性能告警",
          "ja_JP": "",
          "es_ES": ""
        },
        {
          "default": "Inverter",
          "en_US": "Inverter",
          "zh_CN": "逆变器",
          "ja_JP": "",
          "es_ES": ""
        }
      ],
      "orgId": "your_org_id",
      "authUnitId": "your_auth_unit_id",
      "feature": {
        "default": "your_message",
        "en_US": "your_message_en",
        "zh_CN": "your_message_zh",
        "ja_JP": "",
        "es_ES": ""
      },
      "assetId": "your_asset_id",
      "accessKey": "your_access_key",
      "state": 0,
      "linkedStates": "states",
      "callbackUrl":"https://{app-service-address}/app-portal/test/v1/callback?appId=accessKey&messageId=messagett0q22w1299",
      "actionName":
        {
         "en_US":"ACK",
         "zh_CN":"确认",
         "ja_JP": "",
         "es_ES": ""
        }
    }
  ]
}

Return Sample


{
  "code": 0,
  "message": "",
  "data": true
}