> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Chat Script Trigger Reference

Reference for event triggers that call extended scripts



## Trigger

### createRoom

Room creation

**Related methods:**
createRoom - Create Room


#### Synchronous Execution Script

The script is executed synchronously before the room creation process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow room creation |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the room creation process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### deleteRoom

Room deletion

**Related methods:**
deleteRoom - Delete Room


#### Synchronous Execution Script

The script is executed synchronously before the room deletion process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow room deletion |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the room deletion process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### postMessage

Message posting

**Related methods:**
post - Post a message
postByUserId - Post Message by User ID


#### Synchronous Execution Script

The script is executed synchronously before the message posting process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |
| message | [Message](../sdk/#message) | Message |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow message posting |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room
local message = args.message

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the message posting process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |
| message | [Message](../sdk/#message) | Message |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room
local message = args.message

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### subscribeRoom

Room subscription

**Related methods:**
subscribe - Subscribe to a room
subscribeByUserId - Subscribe to a room by User ID


#### Synchronous Execution Script

The script is executed synchronously before the room subscription process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |
| subscribe | [Subscribe](../sdk/#subscribe) | Subscribe |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow room subscription |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the room subscription process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |
| subscribe | [Subscribe](../sdk/#subscribe) | Subscribe |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### unsubscribeRoom

Room Unsubscription

**Related methods:**
unsubscribe - Unsubscribe from a room
unsubscribeByUserId - Unsubscribe from a subscription by User ID


#### Synchronous Execution Script

The script is executed synchronously before the room unsubscription process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |
| subscribe | [Subscribe](../sdk/#subscribe) | Subscribe |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow unsubscribing from the room |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the room unsubscription process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| room | [Room](../sdk/#room) | Room |
| subscribe | [Subscribe](../sdk/#subscribe) | Subscribe |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local room = args.room
local subscribe = args.subscribe

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  



