# Action

* Trong quá trình connect websocket, phía server có thể gửi các các message tới phía client (PSR).

**Message format (json)**

```json
{
	"event": "chunk", // media, hangup, transfer
	"media": {
		"payload": "dGhpc2lzbWVkaWFwYXlsb2Fk......",
		"is_sync": true, // default: false
		"format": "mp3" // [pcm16, mp3 (default)]  
	},
	"data": {
		"extension": "101" // extension to transfer
	}
}
```

Các sự kiện (event) được hỗ trợ bao gồm:

| Event   | Giải thích                                                                                                                                                                                                                                                                                                                                                                                                                                          | Ví dụ                                                                            |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| media   | <p>Gửi một audio (wav format). Thường sử dụng để gửi một file âm thanh dài.<br>Các thuộc tính:<br>- <code>media.payload</code>: base64 encode của file âm thanh<br>- <code>media.is\_sync</code>: nếu <code>true</code> các file âm thanh sẽ được phát tuần tự đến hết. Nếu <code>false</code> file âm thanh đang phát sẽ ngưng nếu có một file tiếp theo được gửi lên.<br>Mặc định: <code>false</code></p>                                         | `{"event": "media", "media": {"payload": "VEVMNFZOLkNPTQ==", "is_sync": false}}` |
| chunk   | <p>Gửi một chunk audio dạng base64. Sử dụng để stream audio từ bot về tổng đài trong thời gian thực.<br><strong>Lưu ý</strong>: đối với chunk, format audio là mp3.<br>Các thuộc tính:<br>- <code>media.payload</code>: base64 encode của chunk âm thanh<br>- <code>media.format</code>: nhận giá trị <code>mp3</code> hoặc <code>pcm16</code>. Nếu format là pcm16, chunk sẽ được convert về mp3 trước khi phát.<br>Mặc định: <code>mp3</code></p> | `{"event": "chunk", "media": {"payload": "VEVMNFZOLkNPTQ==", "format": "mp3"}}`  |
| tranfer | <p>Sử dụng khi cần chuyển cuộc gọi đến một số extension.<br>Các thuộc tính:<br>- <code>data.extension</code>: Số extension muốn nhận transfer</p>                                                                                                                                                                                                                                                                                                   | `{"event": "transfer", "data": {"extension": "101"}}`                            |
| hangup  | Chủ động kết thúc cuộc gọi                                                                                                                                                                                                                                                                                                                                                                                                                          | `{"event": "hangup"}`                                                            |

**Thông số file âm thanh:**

* MP3 (Chunk)
* WAV (Media)
* 16bit
* 8000Hz


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documents.sentechcorp.vn/psr/action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
