> ## Documentation Index
> Fetch the complete documentation index at: https://docs.odella.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a dynamic prompt

> Combine workflow values into a prompt and collect user input before generating a structured result.

# Build a dynamic prompt

This tutorial shows how to build a prompt from earlier workflow values instead of writing one fixed prompt for every run.

## What you will build

The workflow will:

1. Define task instructions.
2. Collect a document type from the user.
3. Insert that value into a prompt.
4. Ask an AI model to produce a structured outline.
5. Return the result.

## 1. Define the instructions

Add a Text block containing the stable instructions:

```text theme={"system"}
Create a concise outline for the requested document type.
Include the purpose, required information, major sections, and review points.
Do not invent facts that were not provided.
```

Keep durable requirements in this block so they are easy to review and update.

## 2. Collect a value

Add a User Input block and ask:

```text theme={"system"}
Which document type should the outline cover?
```

Name the output `documentType`.

## 3. Assemble the dynamic prompt

Add another Text block with interpolation:

```text theme={"system"}
Document type: {{documentType}}

{{instructions}}
```

Connect the first Text block to `instructions` and the User Input output to `documentType`.

## 4. Generate the result

Add an Ask AI block and connect the assembled text to its prompt input. Choose an approved model and connect the response to a Flow Output block named `outline`.

## 5. Test the workflow

Run the workflow with:

* A common document type
* A vague value
* An empty value
* A value containing punctuation or long text

Confirm that the generated prompt contains the expected values and that missing input is handled before the AI step runs.

## Design guidance

* Keep instructions separate from variable values.
* Use descriptive interpolation names.
* Validate required input before generation.
* Avoid placing secrets or credentials in prompts.
* Return structured output when later steps need to process the result.

See [Text Block](/block-reference/data/text), [User Input](/block-reference/io/user-input), and [Ask AI](/block-reference/ai/ai) for field-level references.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.