Updated on 2024-07-04 GMT+08:00

Creating an Interaction Rule Library for Live Rooms

Function

Creates an interaction rule library for live rooms.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/smart-live-interaction-rule-groups

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.

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

Rule index.

rule_name

No

String

Rule name.

enabled

No

Boolean

Whether to enable.

event_type

No

Integer

Event type. - 1: on-screen comment - 2: users joining a live room - 3: giving likes - 4: sending gifts - 10: preset wording

hit_condition

No

HitCondition object

Hit condition.

trigger

No

TriggerProcess object

Trigger

review_config

No

ReviewConfig object

Content review configuration.

Table 5 HitCondition

Parameter

Mandatory

Type

Description

relation

No

String

Condition relationship. The value And or Or RESERVED indicates that the general reply does not check other matching conditions.

priority

No

Integer

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

tags

No

Array of HitConditionTag objects

Matching relationship configuration

Table 6 HitConditionTag

Parameter

Mandatory

Type

Description

tag

No

String

Key fields in the event content.

operation

No

String

Field processing.

  • SUM: accumulation

  • AVG: average

  • COUNT: count

  • NONE: no processing

match

No

String

Match type.

  • 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

value

No

String

Match value

Table 7 TriggerProcess

Parameter

Mandatory

Type

Description

time_window

No

Integer

Processing suppression duration, in second.

–1 indicates the entire livestreaming.

0 indicates no suppression. It is triggered each time.

reply_mode

No

String

Reply type.

  • SYSTEM_REPLY: automatic reply based on the preset script

  • CALLBACK: callback to other services, with the preset script

  • SHOW_LAYER: overlaid layer display, which does not affect the script

  • INTELLIGENT_REPLY: script of an intelligent reply

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

Reply scripts.

reply_audios

No

Array of ReplyAudioInfo objects

Reply audio set. Set audio_url.

reply_order

No

String

Reply sequence.

  • RANDOM: random

  • ORDER: sequential loop

reply_role

No

String

Reply role. The default value is STREAMER.

  • STREAMER: streamer

  • CO_STREAMER: co-streamer

robot_id

No

String

Bot ID.

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

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

NOTE:
  • The canvas resolution is 1920 x 1080 in landscape mode (16:9) and 1080 x 1920 in portrait mode (9:16).

dy

Yes

Integer

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

NOTE:

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

layer_index

Yes

Integer

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

NOTE:
  • The layer sequence is an integer starting from 1. The sequence of the bottom layer is 1 and incremented by 1.

Table 10 LayerSizeConfig

Parameter

Mandatory

Type

Description

width

No

Integer

Width (in pixel) of the layer image (relative to the canvas size).

NOTE:

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

height

No

Integer

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

NOTE:

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

Table 11 SmartImageLayerConfig

Parameter

Mandatory

Type

Description

image_url

Yes

String

Image file URL.

display_duration

No

Integer

Image display duration, in second.

  • 0 Display duration rule: If reply_texts and reply_audios are carried, the duration is the same as the voice playback duration.

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

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

Video display duration, in second.

  • 0 Display duration rule: If reply_texts and reply_audios are carried, the duration is the same as the voice playback duration.

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

Table 13 SmartTextLayerConfig

Parameter

Mandatory

Type

Description

text_type

No

String

Text type.

  • DYNAMIC: dynamic text, which requires keyword replacement

  • STATIC: static text

text_context

No

String

Text.

font_name

No

String

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

font_size

No

Integer

Font size (pixel).

The value ranges from 4 to 120.

font_color

No

String

Font color. RGB color value.

display_duration

No

Integer

Text display duration, in second.

  • 0 Display duration rule: If reply_texts and reply_audios are carried, the duration is the same as the voice playback duration.

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

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.

Status code: 400

Table 18 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 401

Table 19 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 500

Table 20 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

POST https://{endpoint}/v1/70b76xxxxxx34253880af501cdxxxxxx/smart-live-interaction-rule-groups

{
  "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.