from notte_sdk import NotteClientclient = NotteClient()storage = client.FileStorage()# Upload a file before the sessionstorage.upload("document.pdf")# Create session with storage attachedwith client.Session(storage=storage) as session: agent = client.Agent(session=session) result = agent.run( task="Upload document.pdf to the portal and download the receipt", url="https://example.com/upload" )# Download files the agent retrievedfor file in storage.list_downloaded_files(): storage.download(file_name=file.name, local_dir="./downloads")
Upload files from your local machine to make them available in sessions:
uploading_files.py
from notte_sdk import NotteClientclient = NotteClient()storage = client.FileStorage()# Upload a file (uses the original filename)storage.upload("report.pdf")# Upload with a custom namestorage.upload("report.pdf", upload_file_name="quarterly_report.pdf")# List uploaded filesfiles = storage.list_uploaded_files()print(f"Uploaded: {files}")
Download files that agents retrieved from websites:
downloading_files.py
from notte_sdk import NotteClientclient = NotteClient()storage = client.FileStorage()with client.Session(storage=storage) as session: agent = client.Agent(session=session) agent.run(task="Download the invoice from the account page")# List downloaded filesdownloaded = storage.list_downloaded_files()print(f"Downloaded: {downloaded}")# Download to local directoryfor file in downloaded: storage.download(file_name=file.name, local_dir="./invoices")
Agents can interact with files on websites when storage is attached:
using_with_agents.py
from notte_sdk import NotteClientclient = NotteClient()storage = client.FileStorage()# Upload files for the agent to usestorage.upload("contract.pdf")storage.upload("signature.png")with client.Session(storage=storage) as session: agent = client.Agent(session=session, max_steps=15) result = agent.run( task=""" 1. Upload contract.pdf to the document portal 2. Add signature.png to the signature field 3. Submit the form 4. Download the signed confirmation """, url="https://example.com/documents", )# Get the confirmation the agent downloadedfor file in storage.list_downloaded_files(): storage.download(file_name=file.name, local_dir="./signed")
Always create and attach storage before starting the session:
attach_before_starting.py
from notte_sdk import NotteClientclient = NotteClient()# Correctstorage = client.FileStorage()storage.upload("file.pdf")with client.Session(storage=storage) as session: # Storage is available pass
Always check for downloaded files after the session ends:
check_downloads.py
from notte_sdk import NotteClientclient = NotteClient()storage = client.FileStorage()with client.Session(storage=storage) as session: agent = client.Agent(session=session) agent.run(task="Download all invoices")# Check what was downloadedfiles = storage.list_downloaded_files()if not files: print("No files were downloaded")else: for f in files: _ = storage.download(file_name=f.name, local_dir="./invoices")