> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/huong-dan-cac-action/file-and-folder/file-read-random-line.md).

# File read random line

File read random line là hành động dùng để mở một file văn bản `.txt` có sẵn, tự động bốc ngẫu nhiên một dòng bất kỳ trong file đó, sau đó lưu nội dung dòng bốc được vào một biến đầu ra.

Hành động này cực kỳ hữu ích khi bạn nuôi tài khoản mạng xã hội (Facebook, X, Instagram...) và muốn lấy ngẫu nhiên một câu bình luận (Comment), một câu trạng thái (Status) hoặc một từ khóa tìm kiếm để kịch bản không bị lặp đi lặp lại một nội dung giống nhau giữa các profile.

🎥 Xem thêm video hướng dẫn: [Tại đây](https://youtu.be/EH7olDLAb9c).

#### Tham số cấu hình:

* File Path: Đường dẫn tuyệt đối dẫn đến file `.txt` chứa danh sách dữ liệu có sẵn trên máy tính.
* Output variable: Tên biến lưu nội dung dòng ngẫu nhiên vừa bốc được.

#### Ví dụ thực tế: Tự động bình luận ngẫu nhiên để tránh spam

Giả sử bạn chuẩn bị sẵn một file danh sách các câu bình luận tích cực lưu tại `D:\GPM\comments.txt`, mỗi câu nằm trên một dòng riêng biệt:

```
Bài viết hay quá bạn ơi!
Tuyệt vời quá ạ.
Thông tin rất bổ ích, cảm ơn chủ thớt.
```

Khi kịch bản điều hướng trình duyệt đến một bài viết và chuẩn bị nhấn bình luận, bạn cấu hình như sau:

* Cách cấu hình:
  * Gọi hành động File read random line.
  * File Path: Điền đường dẫn `D:\GPM\comments.txt`.
  * Output variable: Đặt tên biến lưu kết quả là `$randomComment`.
* Kết quả: Mỗi lần luồng chạy đến bước này (hoặc mỗi profile chạy độc lập), hệ thống sẽ tự động bốc ngẫu nhiên 1 trong 3 dòng trên (Ví dụ: Profile 1 bốc trúng dòng số 3: `"Thông tin rất bổ ích, cảm ơn chủ thớt."` và gán vào biến `$randomComment`). Bạn chỉ cần gọi hành động Key press truyền biến này vào ô bình luận trên website là xong.

<figure><img src="/files/Ov9EgAng2qgm3mG5BUgu" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/huong-dan-cac-action/file-and-folder/file-read-random-line.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
