Updated on 2025-02-10 GMT+08:00

Updating an Interaction Rule Library for Live Rooms

Function

Updates an interaction rule library for live rooms.

Calling Method

For details, see Calling APIs.

URI

PUT /v1/{project_id}/smart-live-interaction-rule-groups/{group_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

group_id

Yes

String

Interaction policy library ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

User token. This parameter is mandatory when token authentication is used.

You can obtain the token by calling the IAM API used to obtain a user token.

Value of X-Subject-Token in the response header.

Authorization

No

String

Authentication information. This parameter is mandatory for AK/SK authentication.

X-Sdk-Date

No

String

Time when the request is sent. This parameter is mandatory for AK/SK authentication.

The format is YYYYMMDD'T'HHMMSS'Z'.

X-Project-Id

No

String

Project ID. This parameter is mandatory for AK/SK authentication.

X-App-UserId

No

String

Third-party user ID, which does not allow Chinese characters.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

group_name

Yes

String

Interaction rule library name.

interaction_rules

No

Array of InteractionRuleInfo objects

Interaction rules.

Table 4 InteractionRuleInfo

Parameter

Mandatory

Type

Description

rule_index

No

String

Details:

Rule index. It is used to index a specific rule when the rule is triggered.

Constraints:

You do not need to specify it.

Options:

0 to 64 characters

Default value:

N/A

rule_name

No

String

Details:

Rule name.

Constraints:

N/A

Options:

0 to 256 characters

Default value:

N/A

enabled

No

Boolean

Details:

Whether to enable.

Constraints:

N/A

Options:

  • true: enabled
  • false: disabled

Default value:

true

event_type

No

Integer

Details:

Livestreaming event type matched by the rule. The value range is 0 to 100. Options:

1: On-screen comments

2: User joining a room

3: Giving likes

4: Sending gifts

10: Preset script events

Use the actual value.

NOTE:
  • 1, 2, 3, 4: corresponds to event.type in LiveEventReport
  • 10: matches the preset script

Constraints:

N/A

Default value:

N/A

Value range:

0-100

hit_condition

No

HitCondition object

Rule matching condition

trigger

No

TriggerProcess object

Processing after rule matching

review_config

No

ReviewConfig object

Content review configuration.

Table 5 HitCondition

Parameter

Mandatory

Type

Description

relation

No

String

Details:

Condition relationship, specifically, the logical operation relationship between multiple conditions.

Constraints:

N/A

Options:

  • AND: Multiple conditions are met.
  • OR: One of the conditions is met.
  • RESERVED: The general reply does not check other matching conditions.

Default value:

N/A

priority

No

Integer

Details:

Priority. A smaller value indicates a higher priority. The value ranges from 0 to 999. The default value is 500. This parameter is optional.

Constraints:

N/A

Value range:

0-999

Default value:

500

tags

No

Array of HitConditionTag objects

Matching relationship configuration

Table 6 HitConditionTag

Parameter

Mandatory

Type

Description

tag

No

String

Details:

Key fields in the event content.

NOTE:
  • When event_type is set to 1, 2, 3, or 4, the value corresponds to the JSON field deserialized from event.content in LiveEventReport. The following is an on-screen comment event report.

    {

    "timestamp": 1694481224245,

    "type": 1,

    "content": "{"user":{"userId":"2027271526","name":"","level":17,"badge":"","badgeLevel":0},"content":""}"

    }

    To match the on-screen comment content, enter content. To match the user platform level, enter level.

  • 10: Set this field to content.

Constraints:

N/A

Options:

The value contains 0 to 256 characters.

Default value:

N/A

operation

No

String

Details:

Field value processing

Constraints:

N/A

Options:

  • SUM: accumulation
  • AVG: average
  • COUNT: count
  • NONE: no processing

Default value:

NONE

match

No

String

Details:

Match type. You are advised to use REGEX for keyword matching.

Constraints:

N/A

Options:

  • EQUAL: completely equal
  • REGEX: regular expression match
  • MATH_GT: greater than
  • MATH_GE: greater than or equal to
  • MATH_LT: less than
  • MATH_LE: less than or equal to
  • MATH_EQ: numerically equal

Default value:

N/A

value

No

String

Details:

Matched value.

Constraints:

N/A

Options:

The value contains 0 to 1,024 characters.

Default value:

N/A

Table 7 TriggerProcess

Parameter

Mandatory

Type

Description

time_window

No

Integer

Details:

Processing suppression duration, in second.

  • –1: triggered only once throughout the livestream
  • 0: no suppression. It is triggered each time.
  • n: triggered only once within n seconds

Constraints:

N/A

Default value:

N/A

Value range:

-1-7200

reply_mode

No

String

Details:

Reply type.

Constraints:

N/A

Options:

  • SYSTEM_REPLY: automatic reply based on the preset script
  • CALLBACK: callback to other services, with the preset script
  • SHOW_LAYER: display of only overlaid layers, which does not affect the script
  • INTELLIGENT_REPLY: use the configured large model to generate reply scripts

Default value:

N/A

layer_config

No

SmartLayerConfig object

Intelligent layer configuration.

extra_layer_config

No

SmartLayerConfig object

Additional layer, which is used together with the second layer when dynamic text needs to be displayed for products.

reply_texts

No

Array of strings

Details:

Reply scripts.

Constraints:

N/A

Options:

A maximum of five preset scripts are allowed.

A single script contains 0 to 1,024 characters.

Default value:

N/A

reply_audios

No

Array of ReplyAudioInfo objects

Details:

Reply audio set. Set audio_url.

Constraints:

N/A

Options:

A maximum of five preset audio files are allowed.

Default value:

N/A

reply_order

No

String

Details:

Sequence of reading reply scripts.

Constraints:

N/A

Options:

  • RANDOM: randomly
  • ORDER: sequential loop

Default value:

N/A

reply_role

No

String

Details:

Reply role.

Constraints:

N/A

Options:

  • STREAMER: streamer
  • CO_STREAMER: co-streamer, audio-only

Default value:

STREAMER

robot_id

No

String

Details:

Bot ID.

Constraints:

ID of the large model robot configured for intelligent interaction. This parameter is mandatory when reply_mode is set to INTELLIGENT_REPLY.

For details about how to obtain the ID.

Options:

The value contains 0 to 64 characters.

Default value:

N/A

play_type

No

String

Reply playback type.

  • APPEND: added to the end of the playback queue in the scene
  • INSERT: inserted to the end of two audio files or a text sentence
  • PLAY_NOW: inserted immediately. After the instruction is received, the media file is played immediately without waiting till the end of the sentence.

Default value:

PLAY_NOW

Table 8 SmartLayerConfig

Parameter

Mandatory

Type

Description

layer_type

Yes

String

Layer type.

  • IMAGE: image layer
  • VIDEO: video layer
  • TEXT: text layer

asset_id

No

String

ID of the asset overlaid on a video. You do not need to set this parameter for external assets.

position

No

LayerPositionConfig object

Layer position configuration.

size

No

LayerSizeConfig object

Layer size configuration.

image_config

No

SmartImageLayerConfig object

Image layer configuration.

video_config

No

SmartVideoLayerConfig object

Video layer configuration.

text_config

No

SmartTextLayerConfig object

Video layer configuration.

Table 9 LayerPositionConfig

Parameter

Mandatory

Type

Description

dx

Yes

Integer

Details:

X axis position of the pixel in the upper left corner of the image. The coordinate of the upper left corner of the image layout is 0x0.

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image.

Value range:

-1920-3840

Default value:

0

dy

Yes

Integer

Details:

Y axis position of the pixel in the upper left corner of the image. The coordinate of the upper left corner of the image layout is 0x0.

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image.

Value range:

-1920-3840

Default value:

0

layer_index

Yes

Integer

Details:

Layer sequence of an image, video, or person image.

NOTE:

The layer sequence is an integer starting from 1 and incremented by 1.

Constraints:

If duplicate layers exist, the overlay relationship between the duplicate layers is random.

Value range:

1-100

Default value:

100

Table 10 LayerSizeConfig

Parameter

Mandatory

Type

Description

width

No

Integer

Details:

Y axis position of the pixel in the upper left corner of the image. Width (in pixel) of the layer image (relative to the image layout size).

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image.

Value range:

1-7680

height

No

Integer

Details:

Height (in pixel) of the layer image (relative to the image layout size).

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image. |

Value range:

1-7680

Table 11 SmartImageLayerConfig

Parameter

Mandatory

Type

Description

image_url

Yes

String

Image file URL.

display_duration

No

Integer

Details:

Image display duration, in second.

If reply_texts and reply_audios are carried, the duration is the same as the audio playback duration. If reply_texts and reply_audios are not carried, the duration is the same as the audio playback duration of the matched keyword.

Value range:

0-3600

Default value:

0

Table 12 SmartVideoLayerConfig

Parameter

Mandatory

Type

Description

video_url

Yes

String

Video file URL.

video_cover_url

No

String

Video thumbnail file URL.

display_duration

No

Integer

Details:

Image display duration, in second.

If reply_texts and reply_audios are carried, the duration is the same as the audio playback duration. If reply_texts and reply_audios are not carried, the duration is the same as the audio playback duration of the matched keyword.

Value range:

0-3600

Default value:

0

Table 13 SmartTextLayerConfig

Parameter

Mandatory

Type

Description

text_type

No

String

Details:

Text type.

  • DYNAMIC: dynamic text, which requires keyword replacement
  • STATIC: static text

Default value:

DYNAMIC

text_context

No

String

Text.

font_name

No

String

Details:

Font. The following fonts are supported:

  • HarmonyOS_Sans_SC_Black: HarmonyOS bold
  • HarmonyOS_Sans_SC_Regular: HarmonyOS normal
  • HarmonyOS_Sans_SC_Thin: HarmonyOS light
  • fzyouh: Square & lean

Default value:

HarmonyOS_Sans_SC_Black

font_size

No

Integer

Details:

Font size (in pixel).

Value range: [4, 120]. The value range is subject to the actual service.

Value range:

0-120

Default value:

16

font_color

No

String

Details:

Font color. RGB color value.

Default value:

#FFFFFF

display_duration

No

Integer

Details:

Text display duration, in second.

If reply_texts and reply_audios are carried, the duration is the same as the audio playback duration. If reply_texts and reply_audios are not carried, the duration is the same as the audio playback duration of the matched keyword.

Value range:

0-3600

Default value:

0

Table 14 ReplyAudioInfo

Parameter

Mandatory

Type

Description

audio_url

No

String

Audio URL.

audio_name

No

String

Audio name.

Table 15 ReviewConfig

Parameter

Mandatory

Type

Description

no_need_review

No

Boolean

Content review whitelist. This feature is available only for users in the whitelist. The auto review policies apply to other users.

Response Parameters

Status code: 200

Table 16 Response header parameters

Parameter

Type

Description

X-Request-Id

String

Request ID.

Table 17 Response body parameters

Parameter

Type

Description

group_id

String

Interaction rule library ID.

group_name

String

Interaction rule library name.

interaction_rules

Array of InteractionRuleDetailInfo objects

Interaction rules.

create_time

String

Creation time. The format complies with RFC 3339, for example, 2021-01-10T08:43:17Z.

update_time

String

Update time. The format complies with RFC 3339, for example, 2021-01-10T08:43:17Z.

Table 18 InteractionRuleDetailInfo

Parameter

Type

Description

rule_index

String

Details:

Rule index. It is used to index a specific rule when the rule is triggered.

Constraints:

You do not need to specify it.

Options:

0 to 64 characters

Default value:

N/A

rule_name

String

Details:

Rule name.

Constraints:

N/A

Options:

0 to 256 characters

Default value:

N/A

enabled

Boolean

Details:

Whether to enable.

Constraints:

N/A

Options:

  • true: enabled
  • false: disabled

Default value:

true

event_type

Integer

Details:

Livestreaming event type matched by the rule. The value range is 0 to 100. Options:

1: On-screen comments

2: User joining a room

3: Giving likes

4: Sending gifts

10: Preset script events

Use the actual value.

NOTE:
  • 1, 2, 3, 4: corresponds to event.type in LiveEventReport
  • 10: matches the preset script

Constraints:

N/A

Default value:

N/A

Value range:

0-100

hit_condition

HitCondition object

Rule matching condition

trigger

TriggerProcess object

Processing after rule matching

review_config

ReviewConfig object

Content review configuration.

rule_id

String

Interaction rule ID.

create_time

String

Creation time. The format complies with RFC 3339, for example, 2021-01-10T08:43:17Z.

update_time

String

Update time. The format complies with RFC 3339, for example, 2021-01-10T08:43:17Z.

Table 19 HitCondition

Parameter

Type

Description

relation

String

Details:

Condition relationship, specifically, the logical operation relationship between multiple conditions.

Constraints:

N/A

Options:

  • AND: Multiple conditions are met.
  • OR: One of the conditions is met.
  • RESERVED: The general reply does not check other matching conditions.

Default value:

N/A

priority

Integer

Details:

Priority. A smaller value indicates a higher priority. The value ranges from 0 to 999. The default value is 500. This parameter is optional.

Constraints:

N/A

Value range:

0-999

Default value:

500

tags

Array of HitConditionTag objects

Matching relationship configuration

Table 20 HitConditionTag

Parameter

Type

Description

tag

String

Details:

Key fields in the event content.

NOTE:
  • When event_type is set to 1, 2, 3, or 4, the value corresponds to the JSON field deserialized from event.content in LiveEventReport. The following is an on-screen comment event report.

    {

    "timestamp": 1694481224245,

    "type": 1,

    "content": "{"user":{"userId":"2027271526","name":"","level":17,"badge":"","badgeLevel":0},"content":""}"

    }

    To match the on-screen comment content, enter content. To match the user platform level, enter level.

  • 10: Set this field to content.

Constraints:

N/A

Options:

The value contains 0 to 256 characters.

Default value:

N/A

operation

String

Details:

Field value processing

Constraints:

N/A

Options:

  • SUM: accumulation
  • AVG: average
  • COUNT: count
  • NONE: no processing

Default value:

NONE

match

String

Details:

Match type. You are advised to use REGEX for keyword matching.

Constraints:

N/A

Options:

  • EQUAL: completely equal
  • REGEX: regular expression match
  • MATH_GT: greater than
  • MATH_GE: greater than or equal to
  • MATH_LT: less than
  • MATH_LE: less than or equal to
  • MATH_EQ: numerically equal

Default value:

N/A

value

String

Details:

Matched value.

Constraints:

N/A

Options:

The value contains 0 to 1,024 characters.

Default value:

N/A

Table 21 TriggerProcess

Parameter

Type

Description

time_window

Integer

Details:

Processing suppression duration, in second.

  • –1: triggered only once throughout the livestream
  • 0: no suppression. It is triggered each time.
  • n: triggered only once within n seconds

Constraints:

N/A

Default value:

N/A

Value range:

-1-7200

reply_mode

String

Details:

Reply type.

Constraints:

N/A

Options:

  • SYSTEM_REPLY: automatic reply based on the preset script
  • CALLBACK: callback to other services, with the preset script
  • SHOW_LAYER: display of only overlaid layers, which does not affect the script
  • INTELLIGENT_REPLY: use the configured large model to generate reply scripts

Default value:

N/A

layer_config

SmartLayerConfig object

Intelligent layer configuration.

extra_layer_config

SmartLayerConfig object

Additional layer, which is used together with the second layer when dynamic text needs to be displayed for products.

reply_texts

Array of strings

Details:

Reply scripts.

Constraints:

N/A

Options:

A maximum of five preset scripts are allowed.

A single script contains 0 to 1,024 characters.

Default value:

N/A

reply_audios

Array of ReplyAudioInfo objects

Details:

Reply audio set. Set audio_url.

Constraints:

N/A

Options:

A maximum of five preset audio files are allowed.

Default value:

N/A

reply_order

String

Details:

Sequence of reading reply scripts.

Constraints:

N/A

Options:

  • RANDOM: randomly
  • ORDER: sequential loop

Default value:

N/A

reply_role

String

Details:

Reply role.

Constraints:

N/A

Options:

  • STREAMER: streamer
  • CO_STREAMER: co-streamer, audio-only

Default value:

STREAMER

robot_id

String

Details:

Bot ID.

Constraints:

ID of the large model robot configured for intelligent interaction. This parameter is mandatory when reply_mode is set to INTELLIGENT_REPLY.

For details about how to obtain the ID.

Options:

The value contains 0 to 64 characters.

Default value:

N/A

play_type

String

Reply playback type.

  • APPEND: added to the end of the playback queue in the scene
  • INSERT: inserted to the end of two audio files or a text sentence
  • PLAY_NOW: inserted immediately. After the instruction is received, the media file is played immediately without waiting till the end of the sentence.

Default value:

PLAY_NOW

Table 22 SmartLayerConfig

Parameter

Type

Description

layer_type

String

Layer type.

  • IMAGE: image layer
  • VIDEO: video layer
  • TEXT: text layer

asset_id

String

ID of the asset overlaid on a video. You do not need to set this parameter for external assets.

position

LayerPositionConfig object

Layer position configuration.

size

LayerSizeConfig object

Layer size configuration.

image_config

SmartImageLayerConfig object

Image layer configuration.

video_config

SmartVideoLayerConfig object

Video layer configuration.

text_config

SmartTextLayerConfig object

Video layer configuration.

Table 23 LayerPositionConfig

Parameter

Type

Description

dx

Integer

Details:

X axis position of the pixel in the upper left corner of the image. The coordinate of the upper left corner of the image layout is 0x0.

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image.

Value range:

-1920-3840

Default value:

0

dy

Integer

Details:

Y axis position of the pixel in the upper left corner of the image. The coordinate of the upper left corner of the image layout is 0x0.

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image.

Value range:

-1920-3840

Default value:

0

layer_index

Integer

Details:

Layer sequence of an image, video, or person image.

NOTE:

The layer sequence is an integer starting from 1 and incremented by 1.

Constraints:

If duplicate layers exist, the overlay relationship between the duplicate layers is random.

Value range:

1-100

Default value:

100

Table 24 LayerSizeConfig

Parameter

Type

Description

width

Integer

Details:

Y axis position of the pixel in the upper left corner of the image. Width (in pixel) of the layer image (relative to the image layout size).

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image.

Value range:

1-7680

height

Integer

Details:

Height (in pixel) of the layer image (relative to the image layout size).

The image layout resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

Constraints:

The value is the pixel value relative to the image layout. It indicates only the layout position relationship and is irrelevant to the resolution of the output image. |

Value range:

1-7680

Table 25 SmartImageLayerConfig

Parameter

Type

Description

image_url

String

Image file URL.

display_duration

Integer

Details:

Image display duration, in second.

If reply_texts and reply_audios are carried, the duration is the same as the audio playback duration. If reply_texts and reply_audios are not carried, the duration is the same as the audio playback duration of the matched keyword.

Value range:

0-3600

Default value:

0

Table 26 SmartVideoLayerConfig

Parameter

Type

Description

video_url

String

Video file URL.

video_cover_url

String

Video thumbnail file URL.

display_duration

Integer

Details:

Image display duration, in second.

If reply_texts and reply_audios are carried, the duration is the same as the audio playback duration. If reply_texts and reply_audios are not carried, the duration is the same as the audio playback duration of the matched keyword.

Value range:

0-3600

Default value:

0

Table 27 SmartTextLayerConfig

Parameter

Type

Description

text_type

String

Details:

Text type.

  • DYNAMIC: dynamic text, which requires keyword replacement
  • STATIC: static text

Default value:

DYNAMIC

text_context

String

Text.

font_name

String

Details:

Font. The following fonts are supported:

  • HarmonyOS_Sans_SC_Black: HarmonyOS bold
  • HarmonyOS_Sans_SC_Regular: HarmonyOS normal
  • HarmonyOS_Sans_SC_Thin: HarmonyOS light
  • fzyouh: Square & lean

Default value:

HarmonyOS_Sans_SC_Black

font_size

Integer

Details:

Font size (in pixel).

Value range: [4, 120]. The value range is subject to the actual service.

Value range:

0-120

Default value:

16

font_color

String

Details:

Font color. RGB color value.

Default value:

#FFFFFF

display_duration

Integer

Details:

Text display duration, in second.

If reply_texts and reply_audios are carried, the duration is the same as the audio playback duration. If reply_texts and reply_audios are not carried, the duration is the same as the audio playback duration of the matched keyword.

Value range:

0-3600

Default value:

0

Table 28 ReplyAudioInfo

Parameter

Type

Description

audio_url

String

Audio URL.

audio_name

String

Audio name.

Table 29 ReviewConfig

Parameter

Type

Description

no_need_review

Boolean

Content review whitelist. This feature is available only for users in the whitelist. The auto review policies apply to other users.

Status code: 400

Table 30 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 401

Table 31 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 500

Table 32 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

PUT https://{endpoint}/v1/70b76xxxxxx34253880af501cdxxxxxx/smart-live-interaction-rule-groups/26f06524-4f75-4b3a-a853-b649a21aaf66

{
  "group_name" : "Welcome Message"
}

Example Responses

Status code: 200

Succeeded.

{
  "group_id" : "26f06524-4f75-4b3a-a853-b649a21aaf66"
}

Status code: 400

{
  "error_code" : "MSS.00000003",
  "error_msg" : "Invalid parameter"
}

Status code: 401

{
  "error_code" : "MSS.00000001",
  "error_msg" : "Unauthorized"
}

Status code: 500

{
  "error_code" : "MSS.00000004",
  "error_msg" : "Internal Error"
}

Status Codes

Status Code

Description

200

Succeeded.

400

Parameters error, including the error code and its description.

401

Authentication is not performed or fails.

500

Internal service error.

Error Codes

See Error Codes.