Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.narada.ai/llms.txt

Use this file to discover all available pages before exploring further.

The prompt_for_user_input method shows a form in the Narada browser UI and waits for the user to provide values for one or more workflow variables. Use this when a Python agent needs structured input before it can continue.
For a higher-level guide covering both human-in-the-loop methods, see Human-in-the-Loop Steps.

Method Signature

async def prompt_for_user_input(
    self,
    *,
    step_id: str,
    variables: list[PromptForUserInputVariable],
    prompt_message: str | None = None,
    timeout: int | None = 300,
) -> dict[str, Any]

Parameters

step_id
str
required
A stable identifier for this prompt step.
step_id="collect-report-filters"
variables
list[PromptForUserInputVariable]
required
The variables to ask the user to fill. Each variable has:
  • name: variable name
  • type: one of string, number, boolean, enum, dataTable, object, or array
  • required: whether the user must provide a value
  • enum_values: allowed values for enum variables
variables=[
    {"name": "region", "type": "enum", "required": True, "enum_values": ["west", "east"]},
    {"name": "max_accounts", "type": "number", "required": True},
    {"name": "notes", "type": "string", "required": False},
]
prompt_message
str | None
default:"None"
Text to show above the generated input fields. Use this to explain what the user should enter in plain language.
prompt_message="Enter the Jira project where the requirements are located."
timeout
int | None
default:"300"
Maximum time in seconds to wait for the user response. The default is 300 seconds, and the maximum is 3600 seconds.

Return Value

Returns a dictionary keyed by variable name:
{
    "region": "west",
    "max_accounts": 25,
}
Optional variables may be omitted if the user leaves them blank. If the interaction is cancelled or aborted, the method raises UserAbortedError. For dataTable variables, returned values use the canonical table shape:
{
    "columnNames": ["Name", "Email"],
    "rows": [
        ["Ada Lovelace", "ada@example.com"],
        ["Grace Hopper", "grace@example.com"],
    ],
}

Example

import asyncio
from narada import Narada, UserAbortedError

async def main():
    async with Narada() as narada:
        window = await narada.open_and_initialize_browser_window()

        try:
            values = await window.prompt_for_user_input(
                step_id="collect-search-options",
                variables=[
                    {"name": "search_query", "type": "string", "required": True},
                    {"name": "max_results", "type": "number", "required": True},
                    {
                        "name": "source",
                        "type": "enum",
                        "required": False,
                        "enum_values": ["web", "crm", "docs"],
                    },
                ],
                prompt_message="Choose what to search for and how many results to return.",
                timeout=300,
            )
        except UserAbortedError:
            print("The prompt was cancelled.")
            return

        response = await window.agent(
            prompt=(
                f"Search {values.get('source', 'web')} for "
                f"{values['search_query']} and return the top {values['max_results']} results."
            )
        )
        print(response.output.content)

if __name__ == "__main__":
    asyncio.run(main())