> For the complete documentation index, see [llms.txt](https://university.mindstudio.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university.mindstudio.ai/building-ai-agents/blocks-reference/generate-text-block.md).

# Generate Text Block

The Generate Text Block sends a text prompt to an AI model and returns the AI Model’s response.

## Configurations

### **Prompt**

Define the instructions sent to the AI model. Use `{{variables}}` to make the prompt dynamic and context-aware.

[Learn about variables →](/building-ai-agents/variables.md)

### **Response Behavior**

Choose how the AI response is handled:

* **Display to User (Default)**: Shows the response to the end user.
* **Assign to Variable:** Creates a new variable and saves the AI model’s response to it. Enter a `variable_name` \*\*\*\*to store the response for later use in the workflow.

### Output Schema

Choose the format of the AI response:

#### **Text (Default):**&#x20;

Outputs plain or markdown-formatted text, suitable for display or emails.

#### **JSON:**&#x20;

Outputs the response in JSON format, ideal for structured data outputs required for integrations or further processing via code.

**Example Schema:**

```json
{
    "title": "string",
    "summary": "string",
    "date": "string"
}
```

#### **CSV:**&#x20;

Outputs data in CSV format, ideal for tabular data or spreadsheets.

**Example Schema:**

```markdown
Title,Summary,Date
```

For both JSON and CSV outputs, you can explicitly define the output structure by providing a sample output schema.

### **Model Settings**

The default setting is inherited from the underlying model configured in the **Model Settings Tab**. You can override this setting by choosing and configuring a different AI Model specifically for this block.

* **Model Selection**: Choose a different model if needed for the block.
* **Temperature**: Adjust randomness in the response:
  * Lower values = more predictable, consistent results.
  * Higher values = more creative, varied responses.
* **Response Length**: Limit the output size in tokens to suit your needs.

## **Using Conditional Logic in Your Prompt**

The Generate Text Block supports conditional logic to dynamically adjust the text prompt based on workflow variables. This is done using `{{#if}}`, `{{else}}`, and `{{/if}}` statements.

### **How to Use Conditionals**:

#### **Basic Syntax**:

```markdown
{{#if myVariable}}
Use {{myVariable}} to perform this task.
{{else}}
Perform a default action if myVariable is undefined.
{{/if}}
```

**Example:**

```markdown
{{#if customerName}}
Write a thank-you email to {{customerName}}, highlighting our latest offers.
{{else}}
Write a general thank-you email to all customers, highlighting our latest offers.
{{/if}}
```

#### **Nested Conditionals**:

Combine multiple `{{#if}}` statements for complex logic:

```markdown
{{#if userType}}
    {{#if isPremium}}
    Generate a personalized message for our premium user {{userType}}.
    {{else}}
    Generate a message for our standard user {{userType}}.
    {{/if}}
{{else}}
Generate a message for a general audience.
{{/if}}
```


---

# 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://university.mindstudio.ai/building-ai-agents/blocks-reference/generate-text-block.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.
