# Creating Dynamic User Inputs

{% embed url="<https://youtu.be/k80ewAADazw>" %}

Dynamic user inputs allow your AI workflows to adapt and respond to earlier outputs by presenting users with choices or prompts that reflect prior data. This approach makes your AI agents more interactive, relevant, and powerful.

### Scenario: Extracting Entities from a Scraped URL

In a basic setup, you might scrape a URL and extract entities (e.g., people, organizations) mentioned in an article. The next step could involve presenting the user with these entities to choose one for further research.

To do this:

1. Use a **Generate Text** block to return a list of entities in a specific JSON format.
2. The JSON should be an array of objects, each with `label` and `subtitle` keys:

   ```json
   [
     { "label": "NASA", "subtitle": "Space agency mentioned in article" },
     { "label": "SpaceX", "subtitle": "Private aerospace company" }
   ]
   ```
3. Save this as a variable, e.g., `entities`.

### Adding a Dynamic User Input Block

1. Add a **User Input** block.
2. Select **Text Choice**.
3. Set the **prompt** (e.g., "Which entity would you like to research further?").
4. Under **Dynamic Source**, specify the variable holding your JSON (e.g., `entities`).
5. The selected `label` will be stored as the input value.

This enables workflows to dynamically populate input options based on AI-generated data.

### Advanced Use Case: Refining Research Topics

Sometimes user input is too broad (e.g., just entering "dogs"). To handle this, MindStudio offers a **User Context** block to gather deeper context through AI-generated questions.

#### How It Works:

1. Collect a general topic input from the user.
2. Use a **User Context** block:
   * Set the topic as input.
   * Provide a prompt like:\
     \&#xNAN;*"Help the user refine the topic they’d like to research. Gather more contextual information in order to perform a full research report."*
   * Choose the **Interview Depth** (Quick, Medium, or Thorough).
   * Set a **Maximum Question Limit**.
   * Save the results in a variable, e.g., `topicDetails`.
3. Use `topicDetails` downstream to:
   * Generate refined search queries
   * Provide detailed context to summarization or report-generation blocks

This results in much more specific, targeted output.

### Example: Deep Research Agent Flow

1. Collect `topic` from the user.
2. Run a **User Context** block to gather more details.
3. Use `topicDetails` to generate Google search queries.
4. Scrape and summarize each result in sub-workflows.
5. Aggregate findings and generate a detailed report.

This method creates highly accurate and contextual results.

### Benefits of Dynamic Inputs

* **User-Adaptive**: Tailors the experience based on AI or previous input
* **Flexible**: Works with structured JSON or free-text context
* **Scalable**: Enables detailed processing of dynamic lists or open-ended tasks

### Summary

Use dynamic user inputs when:

* The user's next step should be informed by previous AI outputs
* You need to collect deeper, more relevant context
* You want to make AI workflows more flexible and responsive

Dynamic inputs are essential for building smart, adaptive AI agents that can guide users and gather meaningful context in real time.


---

# Agent Instructions: 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:

```
GET https://university.mindstudio.ai/2-workflow-mastery/creating-dynamic-user-inputs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
