---
url: /en/paas/user-notify.md
---
## Overview

`Cloud Native Build` supports users to subscribe to system events and send messages to the configured callback URL.

## Workflow

```mermaid
  sequenceDiagram
    participant Cloud Native Build
    participant Notification Callback URL
    participant Third-party Messaging Service
    participant User to be notified
    Cloud Native Build->>Notification Callback URL: 1. send user notify message
    Notification Callback URL->>Third-party Messaging Service: 2. parse the message and send to message service
    Third-party Messaging Service->>User to be notified: 3. notify user and show the message
```

## Notification Configuration

After logging into the admin management platform, click `Admin Console` -> `System Hook Configuration` -> `Create System Hook` to enter the configuration page.
![user\_notify\_settings](/images/admin-hook-setting.png)

The configuration parameters required for user notification are as follows:

| Parameter Name | Type    | Required | Description |
|:----------:|:------:  |:--:|:-----------------------:|
| URL | String   | Y  | Notification callback URL. Cloud Native Build will send notification messages to this address. |
| Type | String   | Y  | Select `User Notification` |
| Trigger | String   | Y  | Subscribed event types, multiple selections allowed |
| Token | String   | N  | Used for token authorization verification of the callback URL, optional |

## Event Types

`Cloud Native Build` supports the following or more event types:

* pull request
  * New comment
  * New assignee
  * New reviewer
  * Status change
  * New review
* issue
  * New comment
  * New assignee
  * Status change
* Repository
  * Archive
  * Delete
  * Transfer
  * Member role change
* Organization
  * Transfer
  * Member role change
* User
  * @user

## Notification Message Structure

### Notification Header

* `Content-Type`: "application/json;charset=utf-8"
* \`X-CNB-Event": "System Hook", identifies the notification message event
* `X-CNB-Token`: If an authorization token is configured (see `Notification Configuration`), this field will be included

### Notification Body

```json
{
  "touser": "UserID1|UserID2|UserID3", 
  "msgtype": "text", 
  "text": {
    "content": "There is a new PR to be processed"
  }
}
```

Parameter descriptions:

| Parameter Name | Type    | Required | Description |
|:-------:|:------:  |:--:|:-----------------------------------------:|
| touser  | String   | Y  | Specifies the members to receive the message, a list of member IDs (multiple recipients separated by |, up to 1000). |
| msgtype | String   | Y  | Message type, fixed as: text |
| content | String   | Y  | Message content, maximum 2048 bytes |

### Notification Message Example

Taking pull request new review as an example, when the reviewer approves the PR, the following notification message will be sent:

```text
admin1 approved PR #1

feat: init
https://cnb.share.ralphlauren.cn/test/test-repo/-/pulls/1
```

Request body content:

```json
{
  "touser": "123",
  "msgtype": "text",
  "text": {
    "content": "admin1 approved PR #1\n\nfeat: init\ncnb.share.ralphlauren.cn/test/test-repo/-/pulls/1"
  }
}
```
