> 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/automate-en/action-guide/file-and-folder/file-read-random-line.md).

# File read random line

File read random line is an action used to open an existing `.txt` text file, randomly select any line from that file, and then save the content of the selected line into an output variable.

This action is extremely useful when you manage social media accounts (Facebook, X, Instagram...) and want to randomly retrieve a comment, a status, or a search keyword so that the script does not repeat the same content across different profiles.

🎥 Watch the tutorial video: [Here](https://youtu.be/EH7olDLAb9c).

#### Configuration parameters:

* File Path: The absolute path to the `.txt` file containing the available data list on your computer.
* Output variable: The name of the variable that stores the content of the randomly selected line.

#### Practical example: Automatically comment randomly to avoid spam

Suppose you have prepared a file with a list of positive comments stored at `D:\GPM\comments.txt`, with each comment on a separate line:

```
Great post!
Absolutely wonderful.
Very useful information, thank you to the author.
```

When the script navigates the browser to a post and is about to click comment, you configure as follows:

* Configuration steps:
  * Call the action File read random line.
  * File Path: Enter the path `D:\GPM\comments.txt`.
  * Output variable: Name the variable that stores the result as `$randomComment`.
* Result: Each time the flow reaches this step (or each profile runs independently), the system will automatically randomly select one of the three lines above (For example: Profile 1 selects line 3: `"Very useful information, thank you to the author."` and assigns it to the variable `$randomComment`). You just need to call the Key press action to input this variable into the comment box on the website.

<figure><img src="https://2961903581-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpIRrmOLZkhHBXdAiidIw%2Fuploads%2Fgit-blob-431a9b97c89b7e189ba35abf1e17f11a3b025bf2%2Fff-06.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gpmautomate.com/automate-en/action-guide/file-and-folder/file-read-random-line.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
