> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simular.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulang v0 examples

> Example prompts and Simulang v0 snippets for Simular Pro — the in-app v0 action vocabulary.

The best way to master Simular Pro is to learn from the example instructions (prompts) and corresponding **Simulang v0** code on this page.

Just run the instructions on your Simular Pro to reproduce similar **Simulang v0** code, or copy the snippets on this page and execute them in the app.

<Note>
  **Simulang v0 only — not the latest Simulang.** These examples apply **only** to **Simulang v0** embedded in **Simular Pro**. They do **not** match the current standalone Simulang CLI, `simulang-js`, or other **newer Simulang** surfaces; syntax and actions can differ. Use this page with the [Simulang v0 API reference](/simular-pro/simulang). For the latest scripting model, see the [Simulang Primer](/simulang/simulang-primer) and [Simulang with Claude Code](/simulang/simulang-claude-code).
</Note>

Find out how to:

* [Read structured information](/simular-pro/examples#reading-structured-information)
* [Repeat a task on multiple objects](/simular-pro/examples#repeating-a-task-on-multiple-objects-on-a-page)
* [Write structured output](/simular-pro/examples#structured-information-output)
* [Locate an element precisely](/simular-pro/examples#clicking-on-ui-elements)

You can always refer to the [Simulang v0 API documentation](/simular-pro/simulang) if you need a refresher on each Simulang v0 action.

<Warning id="warning-about-machine-configurations">
  Most of the **Simulang v0** code on this page was generated in one shot from the instructions.
  Since there may be differences in individual machine configurations (e.g. browser settings), we recommend that you double check the Simulang v0 snippets before executing.
</Warning>

<Tip>
  If Simular Pro did not click on an element you intended, try these [various methods](#clicking-on-ui-elements) for element localization.
</Tip>

## Reading structured information

Many workflows start with extracting information from an application or webpage.
Moreover, the extracted information often needs to be represented in a particular structure.
For example:

* A house on sale has the following fields: address, square footage, number of beds and baths, etc.
* An email has these fields: sender address, time sent, title, etc.

This section shows you how to instruct Simular Pro to extract information from diverse sources into structured forms.
The resulting information will be ready for downstream workflow steps, such as [iterating a subtask over multiple elements](#repeating-a-task-on-multiple-objects-on-a-page) or [writing structured outputs to files](#structured-information-output).

### Community and communication applications: Extracting channel names on a desktop community app

<CodeGroup>
  ```text Instruction theme={null}
  Open Discord
  Get the page content and extract the top 10 server names visible in the left sidebar.
  Do not include direct messages.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Open Discord
        open({app: "Discord"});

        let servers = [];

        // Get page content and analyze servers
        var content = pageContent();
        // Extract list of servers from the sidebar
        var serverList = ask({
            prompt: "List the top 10 Discord server names visible in the left sidebar. Do not include the direct messages. Return as JSON array. Do not say anything else.",
            context: content
        });
        servers = JSON.parse(serverList);

        return servers;
    }
    ```
  </CodeGroup>
</Expandable>

### Shopping: Get all store locations of a grocery chain

<CodeGroup>
  ```text Instruction theme={null}
  Go to Wegmans stores webpage.
  Get all the locaitons and print them out.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Open Wegmans stores webpage
        open({url: "https://www.wegmans.com/stores"});
        wait({waitTime: 2});
        
        // Get page content and extract all locations
        var content = pageContent();
        var locationsResponse = ask({
            prompt: "Extract all store locations from this page. Return a JSON array of location names (cities/towns where Wegmans stores are located). Do not say or explain anything else, just return the requested data.",
            context: content
        });
        
        var locations = JSON.parse(locationsResponse);
        
        // Print out all locations
        console.log("Wegmans Store Locations:");
        for (let i = 0; i < locations.length; i++) {
            console.log(`${i + 1}. ${locations[i]}`);
        }
        
        return {status: "completed", totalLocations: locations.length, locations: locations};
    }
    ```
  </CodeGroup>
</Expandable>

### Social media URL scraping: Get a company's social media URLs

<CodeGroup>
  ```text Instruction theme={null}
  Go to simular.ai
  Get all of their social media URLs and print them out
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Go to simular.ai
        open({url: "https://simular.ai"});
        wait({waitTime: 3});
        
        // Get page content
        const content = pageContent();
        
        // Ask for social media URLs with explicit JSON format request
        const result = ask({
            prompt: "Find all social media URLs on this page (Twitter, LinkedIn, YouTube, Facebook, Instagram, Discord, etc.). Return as a JSON array of URLs only. Do not say or explain anything else, just return the requested data.",
            context: content
        });
        
        // Parse the JSON response
        const socialMediaUrls = JSON.parse(result);
        
        // Print out all social media URLs
        console.log("Social media URLs found on simular.ai:");
        for (const url of socialMediaUrls) {
            console.log(url);
        }
        
        return {success: true, socialMediaUrls: socialMediaUrls};
    }
    ```
  </CodeGroup>
</Expandable>

### News: Get all headlines from a news site

<CodeGroup>
  ```text Instruction theme={null}
  Go to techcrunch, get all the news headlines, and print them out.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Open TechCrunch website
        open({url: "https://techcrunch.com"});
        wait({waitTime: 3});
        
        // Get page content
        const content = pageContent();
        
        // Ask LLM to extract all news headlines
        const headlinesResponse = ask({
            prompt: "Extract all news headlines from this TechCrunch page. Return only a JSON array of headline strings. Do not include any other text or explanation.",
            context: content
        });
        
        // Parse the JSON response
        const headlines = JSON.parse(headlinesResponse);
        
        // Print out all headlines
        console.log("TechCrunch News Headlines:");
        console.log("==========================");
        
        for (let i = 0; i < headlines.length; i++) {
            console.log(`${i + 1}. ${headlines[i]}`);
        }
        
        return {success: true, headlinesCount: headlines.length};
    }
    ```
  </CodeGroup>
</Expandable>

### Investing: Get an investment firm's list of portfolio companies

<CodeGroup>
  ```text Instruction theme={null}
  Go to a16z's portfolio page and get all the features company names on the page.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Open Chrome and navigate to a16z portfolio page
        open({url: "https://a16z.com/portfolio"});
        
        let allCompanies = new Set();

        // Get current page content
        let content = pageContent();
        
        // Extract visible company names
        let response = ask({
            prompt: "This is the a16z portfolio page. List all visible featured portfolio company names on the page. Do not include a16z itself or any navigation elements. Return as JSON array of strings. Do not say or explain anything else, just return the requested data.",
            context: content
        });
        
        allCompanies = JSON.parse(response);
        
        // Convert to sorted array and display results
        let sortedCompanies = Array.from(allCompanies).sort();
        
        console.log(`Found ${sortedCompanies.length} featured companies on a16z's portfolio page:`);
        console.log(sortedCompanies.join("\n"));
        
        return {
            success: true,
            totalCompanies: sortedCompanies.length,
            companies: sortedCompanies
        };
    }
    ```
  </CodeGroup>
</Expandable>

### Email management: Get the sender, date, and summary of the first unread email.

<CodeGroup>
  ```text Instruction theme={null}
  Go to gmail.com
  Click the first unread email
  From the email content, get: sender email address, date, summary of topic
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Go to Gmail
        open({url: "https://gmail.com"});
        wait({waitTime: 3});
        
        // Click the first unread email
        clickFirstUnreadEmail();
        
        // Get email information
        let emailInfo = getEmailInfo();
        
        // Output the results
        console.log(`Sender Email: ${emailInfo.senderEmail}`);
        console.log(`Date: ${emailInfo.date}`);
        console.log(`Summary: ${emailInfo.summary}`);
        
        return emailInfo;
    }

    //@ Click the first unread email
    function clickFirstUnreadEmail() {
        let content = pageContent();
        let firstUnreadEmail = ask({
            prompt: "Find the first unread email in the inbox and return its subject line or identifying text that can be clicked. Return only the clickable text, nothing else.",
            context: content
        });
        
        click({concept: firstUnreadEmail});
        wait({waitTime: 2});
    }

    //@ Get email information including sender, date, and summary
    function getEmailInfo() {
        let content = pageContent();
        let emailData = ask({
            prompt: "From this email content, extract: 1) sender email address, 2) date of the email, 3) a brief summary of the topic/subject. Return as JSON with keys 'senderEmail', 'date', 'summary'. Do not say or explain anything else, just return the requested JSON data.",
            context: content
        });
        
        return JSON.parse(emailData);
    }
    ```
  </CodeGroup>
</Expandable>

### Real estate: Get address, number of bedrooms and bathrooms, square footage, and price of homes in Palo Alto

<CodeGroup>
  ```text Instruction theme={null}
  Go to redfin palo alto zip 14325
  Get all the address, number of bed, number of bath, square feet, and price of the houses
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Open Chrome and go to Redfin Palo Alto
        open({app: "Google Chrome"});
        wait({waitTime: 2});
        
        // Navigate to Redfin Palo Alto
        press({key: "l", cmd: true});
        type({text: "redfin.com/city/14325/CA/Palo-Alto", withReturn: true});
        wait({waitTime: 3});
        
        // Get all house listings data
        let houseData = getHouseListings();
        
        // Log the results
        console.log("House listings in Palo Alto:");
        for (let i = 0; i < houseData.length; i++) {
            console.log(`House ${i + 1}:`);
            console.log(`Address: ${houseData[i].address}`);
            console.log(`Bedrooms: ${houseData[i].bedrooms}`);
            console.log(`Bathrooms: ${houseData[i].bathrooms}`);
            console.log(`Square Feet: ${houseData[i].squareFeet}`);
            console.log(`Price: ${houseData[i].price}`);
            console.log("---");
        }
        
        return {status: "completed", houses: houseData};
    }

    //@ Get all house listings with address, bedrooms, bathrooms, square feet, and price
    function getHouseListings() {
        // Get page content
        let content = pageContent();
        
        // Ask LLM to extract house data
        let result = ask({
            prompt: "Extract all house listings from this Redfin page. For each house, get: address, number of bedrooms, number of bathrooms, square feet, and price. Return as a JSON array with objects containing fields: address, bedrooms, bathrooms, squareFeet, price. Do not say or explain anything else, just return the requested JSON data.",
            context: content
        });
        
        let houseData = JSON.parse(result);
        return houseData;
    }
    ```
  </CodeGroup>
</Expandable>

## Repeating a task on multiple objects on a page

Having successfully used Simular Pro to [read structured information](#reading-structured-information), such as getting

1. all the names of companies on a page, or
2. all the store locations of a grocery chain, or
3. all the influencer channel names, etc.

now you may need to repeat some task on each of those items, such as:

1. checking each company's stock prices,
2. each grocery store's items on sale
3. each influencer's subscriber count

The following examples show how to instruct Simular Pro to iterate through all the items and do a follow-up task reliably on each item.

### Opening and reading all Simular blog posts

<CodeGroup>
  ```text Instruction theme={null}
  Go to simular.ai/blog
  Get all the blog post URLs
  For each blog post URL, open it, extract the post title and a short summary, then close the tab.
  Print out the post titles and summaries.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    //@ Go to simular.ai/blog and get all blog post URLs
    function getBlogPostUrls() {
        open({url: "simular.ai/blog"})
        wait({waitTime: 3})
        
        var content = pageContent()
        
        var result = ask({
            prompt: "Find all blog post URLs on this page. Return as a JSON array of complete URLs only. Do not say or explain anything else, just return the requested data.",
            context: content
        })
        
        return JSON.parse(result)
    }

    //@ Extract title and summary from a blog post
    function extractPostInfo(url) {
        open({url: url})
        wait({waitTime: 3})
        
        var content = pageContent()
        
        var result = ask({
            prompt: "Extract the blog post title and create a short summary (2-3 sentences) of the main content. Format as a JSON object with fields 'title' and 'summary'. Do not say or explain anything else, just return the requested data.",
            context: content
        })
        
        return JSON.parse(result)
    }

    function main() {
        // Get all blog post URLs
        var blogUrls = getBlogPostUrls()
        
        var allPosts = []
        
        // Process each blog post
        for (var i = 0; i < blogUrls.length; i++) {
            var url = blogUrls[i]
            
            // Extract title and summary
            var postInfo = extractPostInfo(url)
            postInfo.url = url
            allPosts.push(postInfo)
            
            // Close the current tab
            press({key: "w", cmd: true})
            wait({waitTime: 1})
            
            console.log(`Title: ${postInfo.title}`)
            console.log(`Summary: ${postInfo.summary}`)
            console.log(`URL: ${url}`)
            console.log("---")
        }
        
        return {
            success: true,
            posts: allPosts
        }
    }
    ```
  </CodeGroup>
</Expandable>

## Structured information output

The sections above show you how Simular Pro can [read structured information](#reading-information-from-an-application-or-webpage) and [repeats a task](#repeating-a-task-on-multiple-objects-on-a-page) on 100 webpages - now you need it to write that valuable information somewhere.
This section shows you many options to write structured output to a local file on disk or a web browser application.

If you cannot find an output format you need, just ask us on [Discord](https://discord.gg/E2XfsK9fPV).

### Writing information into a Google Sheet

<CodeGroup>
  ```text Instruction theme={null}
  Open a new Google Sheet
  Add headers Name, Summary, Date
  Write "Simular", "Simular pro can do anything!", "08/30/2025" into the first row.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Create a new Google Sheet
        open({url: "https://sheets.google.com/create"});
        wait({waitTime: 2});
        
        // Add headers
        setGoogleSheetCellValue({cell: "A1", value: "Name"});
        setGoogleSheetCellValue({cell: "B1", value: "Summary"});
        setGoogleSheetCellValue({cell: "C1", value: "Date"});
        
        // Add data to the first row (row 2, since row 1 has headers)
        setGoogleSheetCellValue({cell: "A2", value: "Simular"});
        setGoogleSheetCellValue({cell: "B2", value: "Simular pro can do anything!"});
        setGoogleSheetCellValue({cell: "C2", value: "08/30/2025"});
        
        return {success: true};
    }
    ```
  </CodeGroup>
</Expandable>

### Writing information into Excel

<CodeGroup>
  ```text Instruction theme={null}
  Open a new blank sheet in Excel
  Add headers Name, Summary, Date
  Write "Simular", "Simular pro can do anything!", "08/30/2025" into the first row.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Open Excel and create a new blank sheet
        open({app: "Microsoft Excel"});
        
        // Create new blank workbook
        press({key: "n", cmd: true});
        wait({waitTime: 2});
        
        // Add headers in the first row
        click({concept: "cell A1"});
        type({text: "Name"});
        
        press({key: "tab"});
        type({text: "Summary"});
        
        press({key: "tab"});
        type({text: "Date"});
        
        // Move to the second row and add the data
        click({concept: "cell A2"});
        type({text: "Simular"});
        
        press({key: "tab"});
        type({text: "Simular pro can do anything!"});
        
        press({key: "tab"});
        type({text: "08/30/2025"});
        
        return {success: true};
    }
    ```
  </CodeGroup>
</Expandable>

## Clicking on UI elements

Sometimes, the basic `click({at: <description of some element>})` may not be enough for Simular Pro to identify a unique element.
This may happen when more than one element share the same text description, or when the target element only has a visual label (e.g., image or icon).
In these cases, you have two options:

1. In Settings, enable vision fallback for the click action. Simular Pro will automatically attempt to use the best method for UI localization.
2. Use more precise inputs to the `click` function, as shown by examples below.
   You can find the full specification of inputs to the `click` function [here](simulang#click).

<Tip>Use the element picker tool <img src="https://mintcdn.com/simular/PrNYTyoRhGytL_hQ/images/picker.png?fit=max&auto=format&n=PrNYTyoRhGytL_hQ&q=85&s=c24b9ec85a6e895d209ceb33eabc7253" style={{
    display: 'inline', 
    verticalAlign: 'middle', 
    borderRadius: '0.5rem',
    width: '20px',   // adjust size here
    height: '20px'   // optional, keeps it square
}} width="42" height="38" data-path="images/picker.png" /> to check the text description of your target element. </Tip>

### Clicking one of multiple elements that have the same description or image.

This pattern is a powerful and fast way to localize a target element whose textual description may not be unique:

```
click({
    at: <something not unique>, 
    spatialRelation: <a comma-separated string of spatial relationships>, 
    anchorConcept: <something unique>
})
```

You may use one from each of the following three spatial relation categories for `spatialRelation`:

* distance: closest, furthest
* positional filters: left, right, above, below,
* containment filters: contains, containedIn

For example, this will find the unique element called "link Introduction" that is above of and closest to a unique element called "heading Simular Pro":

```
click({
    at: "link Introduction", 
    spatialRelation: "above,closest", 
    anchorConcept: "heading Simular Pro"
})
```

Here is an example drawn from this current page:

<CodeGroup>
  ```text Instruction theme={null}
  Go to docs.simular.ai
  Click on Introduction closest to Getting Started
  Click on Introduction closest to Simulang
  Click on Introduction closest to Agent S
  Click on Introduction closest to Simular
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Go to docs.simular.ai
        open({url: "https://docs.simular.ai"});
        
        // Click on Introduction closest to Getting Started
        click({at: "Introduction", spatialRelation: "closest", anchorConcept: "Getting Started"});
        wait({waitTime: 1});
        
        // Click on Introduction closest to Simulang
        click({at: "link Introduction", spatialRelation: "below,closest", anchorConcept: "heading Simulang", mode: "anchorGrounding"})
        wait({waitTime: 1});
        
        // Click on Introduction closest to Agent S
        click({at: "link Introduction", spatialRelation: "above,closest", anchorConcept: "heading Agent S", mode: "anchorGrounding"})
        wait({waitTime: 1});
        
        // Click on Introduction closest to Simular
        click({at: "link Introduction", spatialRelation: "below,furthest", anchorConcept: "link Blog", mode: "anchorGrounding"})
        wait({waitTime: 1});
        
        return {success: true};
    }
    ```
  </CodeGroup>
</Expandable>

When attempting to close a popup window, you may need to distinguish between the close button of the popup window and the close button of the outer application.
You can instruct Simular Pro to click the close button contained in the dialog window.

<Tip>Use the element picker tool <img src="https://mintcdn.com/simular/PrNYTyoRhGytL_hQ/images/picker.png?fit=max&auto=format&n=PrNYTyoRhGytL_hQ&q=85&s=c24b9ec85a6e895d209ceb33eabc7253" style={{
    display: 'inline', 
    verticalAlign: 'middle', 
    borderRadius: '0.5rem',
    width: '20px',   // adjust size here
    height: '20px'   // optional, keeps it square
}} width="42" height="38" data-path="images/picker.png" /> to get the description of the anchor element.</Tip>

<CodeGroup>
  ```text Instruction theme={null}
  Click the close button contained in the group dialog.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        Click({ at: "button close", spatialRelation: "containedIn", anchorConcept: "group dialog Find and replace" });
    }
    ```
  </CodeGroup>
</Expandable>

### Clicking on an element without text description

If your target element is a pure image without any text description, then you should use the vision mode to localize the element:

```
click({at: <describe your element>, mode: "vision"})
```

<Tip>Use the element picker tool <img src="https://mintcdn.com/simular/PrNYTyoRhGytL_hQ/images/picker.png?fit=max&auto=format&n=PrNYTyoRhGytL_hQ&q=85&s=c24b9ec85a6e895d209ceb33eabc7253" style={{
    display: 'inline', 
    verticalAlign: 'middle', 
    borderRadius: '0.5rem',
    width: '20px',   // adjust size here
    height: '20px'   // optional, keeps it square
}} width="42" height="38" data-path="images/picker.png" /> to check whether your target element has any useful text description.</Tip>

<CodeGroup>
  ```text Instruction theme={null}
  Go to docs.simular.ai
  Click the Simular logo using vision
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        // Navigate to docs.simular.ai
        open({url: "https://docs.simular.ai"});
        click({at: "simular logo", mode: "vision"})
    }
    ```
  </CodeGroup>
</Expandable>

Sometimes you may need to click on an empty space on the current screen, such as when applying a signature to some area of a document.

<CodeGroup>
  ```text Instruction theme={null}
  Click the empty space below the date.
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        click({at: "the space below the date", mode: "vision"})
    }
    ```
  </CodeGroup>
</Expandable>

### Clicking on an element using both text and screenshot

If neither specifying spatial relations nor pure vision work, you may need a combination of both to localize an element.
The mode `textAndScreenshot` is able to localize any element that has a text description.

```
click({at: <description of element>, mode: "textAndScreenshot"})
```

You may use any natural language for the description of the element, including any referring expressions (e.g., "link Introduction in the Simulang section")

<CodeGroup>
  ```text Instruction theme={null}
  Open docs.simular.ai
  Click the introduction link in the simulang section
  ```
</CodeGroup>

<Expandable title="Simulang v0">
  <CodeGroup>
    ```javascript Simulang v0 theme={null}
    function main() {
        open({url: "https://docs.simular.ai"})
        click({at: "link Introduction in the Simulang section", mode: "textAndScreenshot"})
    }
    ```
  </CodeGroup>
</Expandable>
