Create Message


Create messages on Application Portal. The message will appear in the message center pop-up window in the upper right corner of the terminal interface.

Prerequisites


  • The OU has obtained the application, or the application is a self-built application in the OU.

  • If this message is an alert about an asset, the asset or the parent node of the asset need to have the tag auth_unit:true. If necessary, you can add tags to assets via the Update Asset API.

Request Format


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

Request Parameters (Body)


Name

Required/Optional

Data Type

Description

messages

Required

MessageProduceDTO Struct

The message details. MessageProduceDTO Struct >>

MessageProduceDTO Struct


Name

Required/Optional

Data Type

Description

messageId

Required

String

The message ID.

type

Required

Integer

The message type. Supports the following values:

  • 0: common message.

  • 1: alert message.

orgId

Required

String

The OU ID. How to get orgId >>

accessKey

Required

String

The access key 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

The message content in its respective locale’s language. To display message content, you need to specify at least one of default or en_US value. For the structure, see Internationalized name struct.

color

Optional

Integer

The color ID to indicate the message severity. You can use the Get Colors of the Message Icon API to get a list of available message icon colors in an OU.

ring

Optional

Integer

The ringtone ID for the message. You can use the Get Message Ringtones API to get the list of available message ringtones in an OU.

tags

Optional

Map

The message tags to be displayed. Only the first 3 are displayed in the page pop-up window. Supports multiple languages. To display tags, you need to specify at least one of default or en_US value. For the structure, see Internationalization name structure >>

produceTime

Required

String

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

zoneOffset

Required

String

The time zone in UTC format, such as “+08:00”.

linkedAppId

Optional

String

The application ID associated with the message. linkedAppId will be used together with linkedMenuCode and linkedStates to form the URL. The end user can jump to the URL by clicking the message. For example: https://{app-service-address}/portal/abc-123-xyz/alarmProcessing?state=site%abc123, where “{app-service-address}” is the environment domain name, “abc-123-xyz” is linkedAppId, “alarmProcessing” is linkedMenuCode, and “site%abc123” is linkedStates.

linkedMenuCode

Optional

String

The menu ID within the application that is associated with the message. linkedMenuCode will be used together with linkedAppId and linkedStates to form the URL. For details, see the description of the linkedAppId parameter. You can use the Get Application Information API to get the menu IDs within the application.

linkedStates

Optional

String

Other custom parameters in the URL. linkedStates will be used together with linkedAppId and linkedMenuCode to form the URL. For details, see the description of the linkedAppId parameter.

feature

Optional

I18nString

The custom description, which will be displayed in the message pop-up window, supports multi-languages. If you need to display the description, specify at least one of default or en_US. For the structure, see Internationalized name structure >>

assetId

Optional

String

The asset ID associated with the message.

authUnitId

Required

String

Verify whether the application has the permission to access an asset and its sub-assets. You need to specify an asset ID. supports an asset ID of the specific device, or the parent node ID of the device, such as the ID of the power station or factory to which the device belongs. The asset of the ID must be tagged with “auth_unit:true” in the asset tree. For example, if an application has the permission to access a photovoltaic power station, the asset ID of the photovoltaic power station can be specified as authUnitId. When the user accesses the application, all asset data and alarm messages of the photovoltaic power station and its sub-nodes can be viewed.

callbackUrl

Optional

String

When the user clicks a button in the message pop-up window, the system initiates a GET request to the specified URL to notify the server that the user has clicked the message button. Both unencoded and encoded URLs are supported:

  • Unencoded: https://{app-service-address}/callback?appId=yourAppAccessKey&messageId=messagett0q22w1299

  • Encoded: https%3a%2f%2f%7bapp-service-address%7d%2fcallback%3fappId%3daccessKey%26messageId%3dmessagett0q22w1299+

Where {app-service-address} is the server address that can accept and process callback requests.

actionName

Optional

I18nString

The name of the custom button in the message pop-up window, which supports multi-language display. It is recommended to specify 2 characters for Chinese and 3 characters for English, such as and “ACK”. If this parameter is not provided, the button will not be displayed. If the button needs to be displayed, at least one of default or en_US needs to be specified. For the structure, see Internationalized Name Structure >>

actionPermissionCode

Optional

String

Permission ID, which can be used to restrict the operation permissions of the button. When the user who can see this message has this permission, they can view and click the button in the message pop-up box, otherwise the button will not be displayed. If this parameter is not provided, all users who can see this message can see the button by default.

Response parameters


Name

Data Type

Description

data

Boolean

Whether the message rule is deleted successfully. true means the deletion is successful. false means the deletion fails.

Samples

Request Sample


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

method: POST

requestBody:
{
  "messages": [
    {
      "zoneOffset": "+08:00",
      "linkedMenuCode": "menucode",
      "linkedAppId": "yourAppId",
      "color": 1,
      "ring": 1,
      "messageId": "your_message_id",
      "produceTime": "2022-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",
      "linkedStates": "states",
      "callbackUrl":"https://{app-service-address}/app-portal/test/v1/callback?appId=yourAccessKey&messageId=yourMessageId",
      "actionName":
        {
         "en_US":"ACK",
         "zh_CN":"",
         "ja_JP": "",
         "es_ES": ""
        }
    }
  ]
}

Return Sample


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