Prompting Best Practices

Familiarize yourself with the Bytebot Actions

Knowing the type and format of the actions that Bytebot can produce will help you write better prompts.

You can find the list of available actions in the Action Types section.

Actions break down into categories, void actions that don’t produce a result (Click, AssignAttribute), and extract actions that produce a result (CopyText, CopyAttribute, ExtractTable).

The act method will produce one or more void actions. The extract method will produce exactly one extract action.

Most actions are very simple so they don’t require too much attention: for example the Click action only needs a valid xpath as parameter; but other actions, in particular ExtractTable, are more complex.

For example, take this typical ExtractTable action, which extracts a table from a webpage and returns the data in a structured format:

1 {
2 type: "ExtractTable",
3 xpath: "/html/body/div[1]/div[2]/div[2]/tr",
4 rows:[
5 [
6 {
7 name: "Name",
8 action: {
9 xpath: "/html/body/div[1]/div[2]/div[2]/tr[1]/td[1]",
10 type: "CopyText"
11 }
12 },
13 {
14 name: "Address",
15 action: {
16 xpath: "/html/body/div[1]/div[2]/div[2]/tr[1]/td[2]",
17 type: "CopyText"
18 }
19 },
20 {
21 name: "Link",
22 action: {
23 xpath: "/html/body/div[1]/div[2]/div[2]/tr[1]/td[3]/a",
24 type: "CopyAttribute",
25 attribute: "href"
26 }
27 }
28 ]
30 ...
32 ]
33 }

Write clear and concise Prompts

Formulate your prompts clearly and concisely to ensure Bytebot accurately understands and executes the intended actions.


1// Good practice
2const actions = await bytebot.act('Login with the email [email protected] and the password $securepassword', page);
4// Avoid vague prompts
5const vagueActions = await bytebot.act('[email protected]:$securepassword - do the login thing ', page);

Utilize parameters for sensitive data

Use the parameters option to securely pass sensitive or dynamic information to the prompt, avoiding hard-coded values. This also ensures that sensitive data is not exposed in the prompt text.


1const loginDetails = {
2 EMAIL: process.env.USER_EMAIL,
6const actions = await bytebot.act('Log into the website with email EMAIL and password PASSWORD', page, {
7 parameters: loginDetails

Don’t perform consecutive actions

Bytebot can handle multiple, independent actions in a single prompt, as long as all actions can be executed on the same DOM.

For Example:

1// Multiple actions in a single prompt is fine
2const actions = await bytebot.act("Check the 'male' and '26-30' checkboxes", page);

If you need to perform actions that depend on each other, they must be split into separate prompts.

For example, if you need to access the ‘logout’ section which only appears after you click the ‘profile’ button, you should split the actions into two prompts:

  1. Prompt Bytebot to click the ‘Profile’ button, and execute the action.
1// Multiple actions in a single prompt is fine
2const actions = await bytebot.act("Click on the Profile button", page);
3await bytebot.execute(actions, page);
  1. Prompt Bytebot to click the ‘Logout’ button (which will now exist in the DOM).
1// Multiple actions in a single prompt is fine
2const actions = await bytebot.act("Logout of the dashboard", page);
3await bytebot.execute(actions, page);

Implement error handling

Implement robust error handling to gracefully manage failures or unexpected results from prompts.


1try {
2 const actions = await bytebot.act('Submit the form on the page', page);
3 // Process actions...
4} catch (error) {
5 console.error('Failed to execute prompt:', error);

Implement testing and validation

Thoroughly test prompts in development environments to fine-tune their accuracy and ensure they perform as expected under various conditions.


1// Test the prompt with different page states
2const testPageStates = [/* Array of different page states for testing */];
4for (const state of testPageStates) {
5 try {
6 const actions = await bytebot.act('Click the buy button',;
7 // Validate actions...
8 } catch (error) {
9 console.error(`Prompt failed for state ${}:`, error);
10 }

Prompt Iteration and Improvement

Continuously iterate on and improve your prompts based on testing feedback and real-world usage to enhance accuracy and reliability.


1// Initial prompt
2let actions = await bytebot.act('Show notifications', page);
4// Improved prompt after iteration
5actions = await bytebot.act('Show unread notifications in the header', page);

By adhering to these best practices, developers can effectively leverage the prompt method in the Bytebot SDK to automate web tasks efficiently and securely, ensuring high accuracy and reliability in their applications.