The Window.dispatch_request method is the primary interface for executing automation tasks in the Narada Python SDK. It provides a streamlined way to send natural language commands to browser windows with optional structured output, GIF recording, and chat history management.

Method Signature

async def dispatch_request(
    self,
    *,
    prompt: str,
    clear_chat: bool | None = None,
    generate_gif: bool | None = None,
    output_schema: type[BaseModel] | None = None,
    previous_request_id: str | None = None,
    chat_history: list[RemoteDispatchChatHistoryItem] | None = None,
    additional_context: dict[str, str] | None = None,
    time_zone: str = "America/Los_Angeles",
    user_resource_credentials: UserResourceCredentials | None = None,
    callback_url: str | None = None,
    callback_secret: str | None = None,
    timeout: int = 120,
) -> Response

Parameters

prompt
str
required
The natural language instruction for the automation task. Must be prefixed with /Operator to invoke the web agent.
prompt="/Operator search for 'machine learning jobs' and extract the first 5 results"
clear_chat
bool
default:"True"
Whether to clear the chat history before executing the command. Useful for isolated tasks that should not reference previous context.
clear_chat=True  # Start with fresh context
generate_gif
bool
default:"False"
Whether to capture an animated GIF of the automation process. When enabled, the GIF is automatically saved to your local Narada Downloads directory.
generate_gif=True  # Record automation workflow
output_schema
type[BaseModel] | None
default:"None"
Pydantic model class defining the expected structured output format. When provided, Narada will return data conforming to this schema in the structuredOutput field.
from pydantic import BaseModel, Field

class JobResult(BaseModel):
    title: str = Field(description="Job title")
    company: str = Field(description="Company name")

# Use the schema
output_schema=JobResult
previous_request_id
str | None
default:"None"
Request ID from a previous dispatch to continue or reference the conversation context.
previous_request_id="req_abc123def456"
chat_history
list[RemoteDispatchChatHistoryItem] | None
default:"None"
Custom chat history to provide additional context for the automation task.
additional_context
dict[str, str] | None
default:"None"
Additional key-value pairs providing context information for the automation task.
additional_context={"meetingSummary": "Some important meeting details..."}
time_zone
str
default:"America/Los_Angeles"
Time zone for the automation task, useful for time-sensitive operations.
time_zone="Europe/London"
user_resource_credentials
UserResourceCredentials | None
default:"None"
Credentials for accessing user-specific resources during automation.
callback_url
str | None
default:"None"
Optional webhook URL to receive the response asynchronously. Recommended for long-running tasks.
callback_url="https://your-app.com/webhook/narada"
callback_secret
str | None
default:"None"
Secret for validating webhook requests when using callback_url.
timeout
int
default:"120"
Maximum time in seconds to wait for the automation task to complete.
timeout=300  # 5 minutes for complex tasks

Return Value

The method returns a Response object with the following structure:
requestId
string
required
Unique identifier for tracking the request across the Narada platform.
status
string
required
Completion status of the automation task. Possible values: "success", "error".
response
ResponseContent | None
required
Container for the automation results. None if the task failed.
createdAt
string
required
ISO 8601 timestamp when the request was created.
completedAt
string | None
required
ISO 8601 timestamp when the request completed. None if still in progress.

Examples

import asyncio
from narada import Narada

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

        # Simple automation task
        response = await window.dispatch_request(
            prompt='/Operator search for "Python tutorials" on Google'
        )

        print(f"Status: {response['status']}")
        print(f"Result: {response['response']['text']}")

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

Best Practices

Command Structure

Always prefix automation commands with /Operator to invoke the web agent

Descriptive Prompts

Be specific about your intentions and expected outcomes

Timeout Management

Set appropriate timeouts based on task complexity

Structured Data

Use Pydantic models for reliable data extraction

Command Guidelines

Required Prefix: All automation commands must start with /Operator to invoke the web agent. Commands without this prefix will not be processed.
Specific Instructions: Instead of /Operator click button, use /Operator click the Submit button in the contact form for better accuracy.
  • Use clear, actionable language in your prompts
  • Enable GIF recording for debugging complex automation sequences
  • Implement proper error handling for production applications
  • Set reasonable timeouts based on expected task duration
  • Clear chat history when starting unrelated automation tasks

Integration Patterns

Chaining Requests

# Execute a sequence of related automation tasks
async def automation_workflow(window):
    # Step 1: Navigate and search
    search_response = await window.dispatch_request(
        prompt='/Operator navigate to job board and search for "senior engineer"',
        clear_chat=True
    )

    # Step 2: Extract data using previous context
    extract_response = await window.dispatch_request(
        prompt='/Operator extract job details from the search results',
        previous_request_id=search_response['requestId'],
        output_schema=JobListing
    )

    return extract_response

Parallel Processing

# Run multiple automation tasks simultaneously
async def parallel_automation(narada):
    windows = [
        await narada.open_and_initialize_browser_window()
        for _ in range(3)
    ]

    tasks = [
        window.dispatch_request(prompt=f'/Operator search for "{query}"')
        for window, query in zip(windows, ["AI jobs", "Python jobs", "Remote jobs"])
    ]

    results = await asyncio.gather(*tasks)
    return results