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.
Method Signature
async def user_approval(
self,
*,
step_id: str,
prompt_message: str,
approve_label: str,
reject_label: str,
timeout: int | None = 300,
) -> bool
Parameters
A stable identifier for this approval step.step_id="approve-invoice-submission"
The message shown in the approval card.prompt_message="Submit this invoice for approval?"
The label for the button that returns True.
The label for the button that returns False.
Maximum time in seconds to wait for the user response. The default is 300 seconds, and the maximum is 3600 seconds.
Return Value
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 Agent, BrowserEnvironment, UserAbortedError
async def main():
env = BrowserEnvironment()
agent = Agent(environment=env)
try:
try:
approved = await agent.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 agent.run(prompt="Send the drafted message.")
finally:
await env.close()
if __name__ == "__main__":
asyncio.run(main())