Skip to main content

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:
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:
Name the output documentType.

3. Assemble the dynamic prompt

Add another Text block with interpolation:
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, User Input, and Ask AI for field-level references.