AI agent instructions
AI agent instructions
Functions are serverless deployments of your browser automations that can be invoked via API, scheduled to run automatically, or triggered by events.
What are Functions?
Functions turn your automation scripts into:- API endpoints you can call with HTTP requests
- Scheduled jobs that run on a cron schedule
- Reusable workflows accessible from anywhere
- Shareable automations for your team
- ✅ Run on Notte’s infrastructure (no servers to manage)
- ✅ Scale automatically based on demand
- ✅ Provide built-in logging and monitoring
- ✅ Can be invoked from any platform (Python, JavaScript, cURL, etc.)
- ✅ Support scheduling and automation
How Functions Work
1. Write Your Script
Create a Python file with arun() function:
basic_function.py
2. Deploy to Notte
Upload your script to create a Function:3. Invoke the Function
Call your Function using either SDK. SetNOTTE_FUNCTION_ID to the deployed function’s ID first:
Large run outputs
The Python and TypeScript SDKs upload individual run results, logs, and variables larger than 1 MiB to private storage. Pythonfunctions.update_run() and TypeScript
fn.updateRun(runId, fields) save a small reference. Python functions.get_run()
and TypeScript fn.getRun() download and verify the full value automatically.
Each stored field can be up to 256 MiB. Small fields continue to use inline updates.
Upgrade your SDK to use this behavior. An inline run update above 8 MiB is
rejected. Reading a run with externally stored fields through an older client
returns an explicit error rather than a partial result.
For HTTP integrations, request a run with ?payload_mode=references. The response
includes payloads descriptors and short-lived payload_urls for the external
fields. Download these URLs without your API authorization header, verify each
field’s size_bytes and base64 SHA-256 checksum, and decode its JSON value.
Function Structure
The Handler Function
Functions must have arun() function that serves as the entry point:
handler_function.py
- Named
run()- this is the entry point - Can accept parameters (passed as
variableswhen invoked) - Should have type hints for clarity
- Should include docstring documentation
- Returns a value (any JSON-serializable type)
Parameters
Define parameters as arguments to therun function:
parameters_example.py
pass_values.py
Return Values
Functions can return any JSON-serializable data:return_values.py
Use Cases
1. Scheduled Scraping
Extract data on a schedule:price_monitor.py
0 9 * * * (Every day at 9 AM)
2. API Endpoints
Expose automation as an API:contact_extractor.py
3. Webhooks
Trigger automations from external events:order_processor.py
4. Batch Processing
Process multiple items in parallel:bulk_data_extract.py
How Functions Fit In
Functions are a deployment layer - they turn any automation into a reusable API.- Session - The cloud browser that runs everything
- Scripted Automation vs Agent - How you control the session
- Function - Deploys your automation as an API with scheduling, versioning, and sharing
- You need to run automation repeatedly
- You want to expose automation as an API
- You need scheduling capabilities
- You want to share automation with team or customers
Function Lifecycle
- Write - Create Python script with
run()function - Deploy - Upload to Notte (creates function ID)
- Version - Notte tracks versions automatically
- Invoke - Call via API, schedule, or webhook
- Execute - Runs on Notte infrastructure
- Monitor - View logs, replays, and results
Best Practices
1. Use Clear Parameters
Define parameters with type hints and descriptions:bp_clear_parameters.py
2. Return Structured Data
Always return JSON-serializable data:bp_return_structured.py
3. Handle Errors Gracefully
Catch exceptions and return meaningful errors:bp_handle_errors.py
4. Add Logging
Log important steps for debugging:bp_add_logging.py
Next Steps
Creating Functions
Learn how to write and deploy Functions
Invocations
Call Functions via API, SDK, or cURL
Schedules
Schedule Functions with cron
Management
Update, version, and monitor Functions