# Extract text from file

### What's it for?

* The client can send files in docx, pdf, rtf, txt or any other format;
* The bot will be able to process the file, or pass the result from the file to other action steps.

### Creating an action to extract text from a file

{% stepper %}
{% step %}

### Go to the “Workflows” section and click the “+ Add” button

<figure><img src="https://2542240793-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnmK9dnkx224HgS0VSB5J%2Fuploads%2FDB1mgblNkq36ErHgfYww%2Fimage.png?alt=media&#x26;token=707cf7d1-714d-442b-b569-1b515f0fb696" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### We choose "Extract text from file"

<figure><img src="https://2542240793-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnmK9dnkx224HgS0VSB5J%2Fuploads%2FdS9J0LKbAULPPV536HaE%2Fimage.png?alt=media&#x26;token=367e3d1d-020e-49ba-a9ca-6a571b7a7bd9" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Go to Settings

<figure><img src="https://2542240793-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnmK9dnkx224HgS0VSB5J%2Fuploads%2FIcNxoPbCBf80rer7idib%2Fimage.png?alt=media&#x26;token=8468434c-eab8-46bd-be5a-3ac3edbc9a00" alt=""><figcaption></figcaption></figure>

* **Action name —** a display name by which you can easily identify the required tool in the general list
* **+ Add Step —** you can trigger multiple webhooks or perform multiple other functions within a single action. For each new webhook, you must add an additional step using the "+ Add Step" button.
* ⚙️(*Bot response rules) —* with this setting, we have the option to choose which step's response will be passed to the bot - from the first, the last, or from all.
* **Argument in which the file will be transferred** — is a field for selecting the argument in which the file will be passed to the function.
* **Export mode —** here you can choose one of two options for extracting text from files:
  1. HTML extraction
  2. Markdown extraction
* **Put the received text into a variable —** enable the option so that after calling the webhook, the received text can be placed in a variable and passed to another function if necessary.
* **Scanned Text Reading Mode** — you can choose one of three modes for reading scanned text:
  1. Do not use text recognition
  2. Use recognition if the file is a PDF and contains at least one image
  3. Always recognize text on images
     {% endstep %}

{% step %}

### **Trigger conditions**

<figure><img src="https://2542240793-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnmK9dnkx224HgS0VSB5J%2Fuploads%2FqwKUUsKnPvYUAz0O6hM8%2Fimage.png?alt=media&#x26;token=8a956947-9f3b-4711-9f45-27a4a88bb285" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
To automatically generate a **Function Name**, fill in the **Action Name** field and press the **auto-generation button** to the right of the function name field.
{% endhint %}

* **Call by LLM model** — the function is called by the LLM model through instructions written to the bot.
* **Trigger call** — the function is called based on a pre-defined event when the specified conditions are met.
* **Function Name** — should describe the main idea of this action. Only English alphabet characters and underscores (\_) are allowed.
* **Function Description** — a description of what this action will do.
  {% endstep %}

{% step %}

### **Action variables**

<figure><img src="https://2542240793-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnmK9dnkx224HgS0VSB5J%2Fuploads%2FYwBp1CiUBGmWS3hClJ2T%2Fimage.png?alt=media&#x26;token=f357f2e4-81a8-4148-9b73-af7cbdfd1fdc" alt=""><figcaption></figcaption></figure>

* **Argument** - since the argument for the function any File by design, in the **Argument** field we write **`file`**.
* **Argument Description** - this field is optional and serves as a description to avoid confusion if there are multiple arguments.

{% hint style="warning" %}
Ensure that the **argument** is written in English and without spaces. You can use English alphabet characters and underscores (`_`).
{% endhint %}
{% endstep %}

{% step %}

### Additional Settings

<figure><img src="https://2542240793-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnmK9dnkx224HgS0VSB5J%2Fuploads%2FBFTMSFvFamLIGr5ABZGj%2Fimage.png?alt=media&#x26;token=81e93d92-90c2-4459-8c24-84746c91b7bd" alt=""><figcaption></figcaption></figure>

* **Stop dialog on call** — after calling the function to "Extract text from file", the dialogue will stop and the bot will stop responding.
* **Do not respond on call** — after calling the "Extract text from file" function, the dialogue will not be stopped, but no response will be sent to the dialogue.
* **Notify on error** — if a function call fails, you will receive a notification.
* **Stop on error** — if the function call fails, the dialog will stop.
* **Error Message** — what text will be returned to the bot in case of an error. We recommend writing something like "An error occurred"
  {% endstep %}
  {% endstepper %}
