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 user_approval method shows an approval card in the Narada browser UI and waits for the user to choose one of two buttons. Use this when a Python agent should not continue until a person explicitly approves or rejects the next action.
For a higher-level guide covering both human-in-the-loop methods, see Human-in-the-Loop Steps.

Method Signature

async def user_approval(
    self,
    *,
    step_id: str,
    prompt_message: str,
    approve_label: str,
    reject_label: str,
    timeout: int | None = None,
) -> bool

Parameters

step_id
str
required
A stable identifier for this approval step.
step_id="approve-invoice-submission"
prompt_message
str
required
The message shown in the approval card.
prompt_message="Submit this invoice for approval?"
approve_label
str
required
The label for the button that returns True.
approve_label="Submit"
reject_label
str
required
The label for the button that returns False.
reject_label="Cancel"
timeout
int | None
default:"None"
Maximum time in seconds to wait for the user response. If omitted, Narada uses the default extension action timeout.

Return Value

approved
bool
True when the user clicks the approve button. False when the user clicks the reject button.
If the interaction is cancelled or aborted, the method raises UserAbortedError.

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:
            approved = await window.user_approval(
                step_id="approve-send-message",
                prompt_message="Send the drafted message to the customer?",
                approve_label="Send",
                reject_label="Do not send",
                timeout=300,
            )
        except UserAbortedError:
            print("The approval step was cancelled.")
            return

        if not approved:
            print("The user rejected the action.")
            return

        await window.agent(prompt="Send the drafted message.")

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