Use Custom Scripts for Advanced Automation
mainThe Custom Script operation allows full Puppeteer API access in a sandboxed environment.
Available Global Objects:
$page: Current page instance.$browser: Browser instance.$puppeteer: Puppeteer library.$input.query: Input query from AI agents (when used as a tool).
AI Agent Integration:
- AI-Generated Scripts: Use
$fromAI()to let an agent write the code dynamically. - Reusable Scripts: Use
$input.queryto accept dynamic parameters from an agent.
// AI agent generates script dynamically
scriptCode: $fromAI('code', 'Generate a Puppeteer script to extract product prices from the homepage')
// Reusable script using AI input
const url = $input.query || 'https://example.com';
await $page.goto(url);
// ... logic ...
// AI agent provides input via query parameter
query: $fromAI('url', 'The website URL to scrape')