> For the complete documentation index, see [llms.txt](https://university.gonexa.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university.gonexa.fr/doc/en/advanced-features/doc-and-flows/generate-document-with-flow.md).

# Generate a document automatically with a flow

Our best-known action, which lets you generate a document automatically

## Action name: "Generate a document"

**Single generation action**

Build your process as you wish (screen, decision, success message...) and add the Gonexa action.

### The 3 parameters of the Generate a document action

* Add an Action element to your flow
* Select the Generate a document action: `apex-gnc__DocumentGenerationInvocable`
* Fill in the following 3 items:

**Output format**\
Takes the value pdf, xlsx, pptx or docx. You can make this value a variable with a screen by creating new Choice resources.

**RecordId**\
Retrieves the ID of the record to generate. Set this value with a Text variable that is available for input.

**TemplateId**\
Retrieves the ID of the document template to generate. This value can be set as a variable in a screen, or selected from the documents based on criteria such as the document name.

* Add a Get Records element to your flow
* Save, activate and test

## Action name: "Generate a document (Future)"

**Single generation action**

This flow action is similar to the Generate a document action, and its configuration is the same. It generates a single document asynchronously, which means it runs in the background. It has the same parameters as the Generate a document action; only the way it runs is different.

{% hint style="danger" %}
**Warning**

Salesforce does not allow more than 50 future actions at the same time, so be careful with record-triggered flows that use this action with a trigger that could be called more than 50 times at once.
{% endhint %}


---

# 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://university.gonexa.fr/doc/en/advanced-features/doc-and-flows/generate-document-with-flow.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.
