Writing a Function
Functions are Python scripts with arun() function that serves as the entry point.
Basic Function
The minimal Function structure:hello_function.py
Function with Parameters
Accept input parameters:greet_function.py
Browser Automation Function
Use Notte SDK for browser automation:scraper_function.py
Deploying Functions
Via SDK
Deploy from Python:deploy_sdk.py
Deployment Options
deployment_options.py
workflow_path(str, required): Path to your Python filename(str, optional): Function display namedescription(str, optional): What the function doesshared(bool, default=False): Whether function is publicly accessible
Function Requirements
The Handler
Must have arun() function:
handler_examples.py
Dependencies
Import Notte SDK and standard libraries:dependencies.py
notte-sdk- Notte SDKrequests- HTTP clientpydantic- Data validation- Standard Python library
- Most common packages
Return Values
Return JSON-serializable data:return_values.py
Parameter Types
Supported Types
parameter_types.py
Type Validation
Use type hints for automatic validation:type_validation.py
Complex Types
Use Pydantic for structured parameters:complex_types.py
Environment Variables
Access secrets securely:environment_variables.py
Error Handling
Graceful Errors
Return error information in results:graceful_errors.py
Raising Exceptions
Let Functions fail explicitly:raising_exceptions.py
Testing Locally
Test Before Deploying
Run your function locally:test_locally.py
Mock API Calls
Test without deploying:mock_api_calls.py
Best Practices
1. Document Parameters
Use clear docstrings:document_params.py
2. Return Structured Data
Use consistent return formats:return_structured.py
3. Add Logging
Log key steps for debugging:add_logging.py
4. Set Timeouts
Prevent functions from hanging:set_timeouts.py
5. Validate Inputs
Check parameters before processing:validate_inputs.py
Examples
Simple Scraper
simple_scraper.py
Form Submission
form_submission.py
Data Extraction
structured_extraction.py

