Act
AI-generatedOverview
This node, named "Stagehand," enables controlling a browser session via the Chrome DevTools Protocol (CDP) using natural language instructions. It connects to a browser instance through a CDP WebSocket URL and performs operations such as acting on the page, extracting structured data, or observing the page state.
Common scenarios where this node is beneficial include:
- Automating complex browser interactions by describing actions in natural language.
- Extracting structured data from web pages without manually coding selectors or parsers.
- Observing page content or behavior to inform subsequent automation steps.
Practical examples:
- Navigating a website and clicking buttons or filling forms by providing simple instructions.
- Extracting product details like title and price from an e-commerce page using a JSON schema or example data.
- Monitoring changes on a page and planning next steps based on observations.
Properties
| Name | Meaning |
|---|---|
| CDP URL | The WebSocket URL for connecting to the Chrome DevTools Protocol of the target browser instance. |
| Instruction | Natural language instruction describing the action or query to perform on the page. |
| Advanced Options | Collection of optional settings: • Enable Caching: Whether to cache Stagehand operations (true/false). • Log Messages: Include internal Stagehand log messages in output (true/false). • Verbose Level: Logging verbosity level with options: No Logs, Only Errors, All Logs. |
Output
The node outputs an array of items, each containing a json object with the following structure:
operation: The operation performed (act,extract, orobserve).result: The result returned by the Stagehand operation:- For Act: Result of executing the instructed action on the page.
- For Extract: Structured data extracted according to the provided schema or example.
- For Observe: Observations or analysis of the page state.
messages(optional): If logging is enabled, an array of internal Stagehand log messages generated during execution.
If an error occurs during execution, the output item will contain an error field describing the failure, alongside partial output if available.
The node does not output binary data.
Dependencies
- Requires a running browser instance accessible via a Chrome DevTools Protocol WebSocket URL.
- Needs an AI language model input connection that provides:
- A model identifier string.
- An API key credential for authentication.
- Uses the external
@browserbasehq/stagehandlibrary to interface with the browser and perform operations. - Requires n8n environment configured to supply the AI model credentials and allow WebSocket connections to the browser.
Troubleshooting
- Missing or invalid CDP URL: Ensure the Chrome browser is launched with remote debugging enabled and the correct WebSocket URL is provided.
- AI Model connection issues: The node requires a valid AI language model input with both model name and API key. Verify these are correctly connected and configured.
- Unsupported operation errors: Only "act", "extract", and "observe" operations are supported. Check the operation parameter value.
- Schema parsing errors (for extract operation): When using JSON Schema, example JSON, or manual Zod code, ensure the syntax is valid and matches expected formats.
- Verbose logging not showing messages: Enable "Log Messages" option and set appropriate verbosity level to capture internal logs.
- Timeouts or failures connecting to the browser: Confirm network connectivity and that the browser instance is reachable at the specified CDP URL.
Links and References
- Chrome DevTools Protocol
- Stagehand GitHub Repository (for more info on the underlying library)
- Zod Validation Library (used for schema validation in extraction)
- n8n Documentation (general guidance on creating and using custom nodes)