Skip to content

Commit 87a6616

Browse files
committed
working version of stagehand browserbase nodes
1 parent 6591760 commit 87a6616

File tree

5 files changed

+1591
-192
lines changed

5 files changed

+1591
-192
lines changed

examples/integrations/n8n/credentials/Browserbase.credentials.ts renamed to examples/integrations/n8n/credentials/BrowserbaseApi.credentials.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
INodeProperties,
66
} from 'n8n-workflow';
77

8-
export class Browserbase implements ICredentialType {
9-
name = 'Browserbase';
10-
displayName = 'Browserbase';
8+
export class BrowserbaseApi implements ICredentialType {
9+
name = 'browserbaseApi';
10+
displayName = 'Browserbase API';
1111
documentationUrl = 'https://docs.browserbase.com/';
1212
properties: INodeProperties[] = [
1313
{
@@ -29,17 +29,28 @@ export class Browserbase implements ICredentialType {
2929
required: true,
3030
description: 'The Project ID for your Browserbase project. You can find this in your Browserbase dashboard.',
3131
},
32+
{
33+
displayName: 'OpenAI API Key',
34+
name: 'openaiApiKey',
35+
type: 'string',
36+
typeOptions: {
37+
password: true,
38+
},
39+
default: '',
40+
required: true,
41+
description: 'The OpenAI API key required for AI operations (act, observe, extract). You can get this from your OpenAI dashboard.',
42+
},
3243
];
3344

34-
authenticate = {
45+
authenticate: IAuthenticateGeneric = {
3546
type: 'generic',
3647
properties: {
3748
headers: {
3849
'X-BB-API-Key': '={{$credentials.apiKey}}',
3950
'X-BB-Project-ID': '={{$credentials.projectId}}',
4051
},
4152
},
42-
} as IAuthenticateGeneric;
53+
};
4354

4455
test: ICredentialTestRequest = {
4556
request: {

examples/integrations/n8n/nodes/Browserbase/BrowserDescription.ts

Lines changed: 109 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export const browserOperations: INodeProperties[] = [
3232
action: 'Get session details',
3333
},
3434
{
35-
name: 'Delete Session',
36-
value: 'deleteSession',
37-
description: 'Delete a browser session',
38-
action: 'Delete a browser session',
35+
name: 'Close Session',
36+
value: 'closeSession',
37+
description: 'Close a browser session (automatically uses previous node\'s session)',
38+
action: 'Close a browser session',
3939
},
4040
],
4141
default: 'createSession',
@@ -151,7 +151,7 @@ const getSessionOperation: INodeProperties[] = [
151151
displayOptions: {
152152
show: {
153153
resource: ['browserSession'],
154-
operation: ['getSession', 'deleteSession'],
154+
operation: ['getSession'],
155155
},
156156
},
157157
},
@@ -171,34 +171,34 @@ export const browserActionOperations: INodeProperties[] = [
171171
},
172172
options: [
173173
{
174-
name: 'Navigate',
175-
value: 'navigate',
176-
description: 'Navigate to a URL',
177-
action: 'Navigate to a URL',
174+
name: 'Act',
175+
value: 'act',
176+
description: 'Perform an action on the page using natural language (requires OpenAI API key)',
177+
action: 'Act on page',
178178
},
179179
{
180-
name: 'Take Screenshot',
181-
value: 'screenshot',
182-
description: 'Take a screenshot',
183-
action: 'Take a screenshot',
180+
name: 'Extract',
181+
value: 'extract',
182+
description: 'Extract structured data from the page (requires OpenAI API key)',
183+
action: 'Extract data',
184184
},
185185
{
186-
name: 'Get Page Content',
187-
value: 'getContent',
188-
description: 'Get page content',
189-
action: 'Get page content',
186+
name: 'Navigate',
187+
value: 'navigate',
188+
description: 'Navigate to a URL',
189+
action: 'Navigate to URL',
190190
},
191191
{
192-
name: 'Click Element',
193-
value: 'click',
194-
description: 'Click on an element',
195-
action: 'Click element',
192+
name: 'Observe',
193+
value: 'observe',
194+
description: 'Observe the page and get available actions (requires OpenAI API key)',
195+
action: 'Observe page',
196196
},
197197
{
198-
name: 'Type Text',
199-
value: 'type',
200-
description: 'Type text into an element',
201-
action: 'Type text',
198+
name: 'Screenshot',
199+
value: 'screenshot',
200+
description: 'Take a screenshot of the page',
201+
action: 'Take screenshot',
202202
},
203203
],
204204
default: 'navigate',
@@ -260,34 +260,6 @@ const browserActionFields: INodeProperties[] = [
260260
},
261261
},
262262
},
263-
{
264-
displayName: 'Selector',
265-
name: 'selector',
266-
type: 'string',
267-
default: '',
268-
placeholder: '.my-element, #button, input[name="username"]',
269-
description: 'CSS selector for the element',
270-
displayOptions: {
271-
show: {
272-
resource: ['browserAction'],
273-
operation: ['click', 'type', 'getContent'],
274-
},
275-
},
276-
},
277-
{
278-
displayName: 'Text',
279-
name: 'text',
280-
type: 'string',
281-
required: true,
282-
default: '',
283-
description: 'The text to type',
284-
displayOptions: {
285-
show: {
286-
resource: ['browserAction'],
287-
operation: ['type'],
288-
},
289-
},
290-
},
291263
{
292264
displayName: 'Screenshot Options',
293265
name: 'screenshotOptions',
@@ -314,10 +286,93 @@ const browserActionFields: INodeProperties[] = [
314286
type: 'string',
315287
default: '',
316288
placeholder: '.screenshot-area',
317-
description: 'CSS selector for element to screenshot',
289+
description: 'CSS selector for element to screenshot (optional)',
318290
},
319291
],
320292
},
293+
{
294+
displayName: 'Action',
295+
name: 'action',
296+
type: 'string',
297+
required: true,
298+
default: '',
299+
placeholder: 'Click the login button',
300+
typeOptions: {
301+
rows: 3,
302+
},
303+
displayOptions: {
304+
show: {
305+
resource: ['browserAction'],
306+
operation: ['act'],
307+
},
308+
},
309+
},
310+
{
311+
displayName: 'Instruction',
312+
name: 'instruction',
313+
type: 'string',
314+
required: true,
315+
default: '',
316+
placeholder: 'Find all clickable buttons on the page',
317+
description: 'Instruction for what to observe on the page',
318+
typeOptions: {
319+
rows: 3,
320+
},
321+
displayOptions: {
322+
show: {
323+
resource: ['browserAction'],
324+
operation: ['observe'],
325+
},
326+
},
327+
},
328+
{
329+
displayName: 'Return Actions',
330+
name: 'returnActions',
331+
type: 'boolean',
332+
default: false,
333+
description: 'Whether to return actionable elements that can be used with the act operation',
334+
displayOptions: {
335+
show: {
336+
resource: ['browserAction'],
337+
operation: ['observe'],
338+
},
339+
},
340+
},
341+
{
342+
displayName: 'Instruction',
343+
name: 'instruction',
344+
type: 'string',
345+
required: true,
346+
default: '',
347+
placeholder: 'Extract all product information from this page',
348+
description: 'Instruction for what data to extract from the page',
349+
typeOptions: {
350+
rows: 3,
351+
},
352+
displayOptions: {
353+
show: {
354+
resource: ['browserAction'],
355+
operation: ['extract'],
356+
},
357+
},
358+
},
359+
{
360+
displayName: 'Schema (JSON)',
361+
name: 'schema',
362+
type: 'json',
363+
required: true,
364+
default: '{\n "type": "object",\n "properties": {\n "title": {\n "type": "string",\n "description": "Page title"\n }\n },\n "required": ["title"]\n}',
365+
description: 'JSON Schema defining the structure of data to extract. Use Zod-compatible schema format.',
366+
typeOptions: {
367+
rows: 10,
368+
},
369+
displayOptions: {
370+
show: {
371+
resource: ['browserAction'],
372+
operation: ['extract'],
373+
},
374+
},
375+
},
321376
];
322377

323378
export const browserFields: INodeProperties[] = [

0 commit comments

Comments
 (0)