Tutorial
Your First Agent
Build your first automation agent with AskUI
In this tutorial, you’ll create your first AskUI agent that automates a real-world task: searching for products on Amazon.
Prerequisites: Make sure you’ve completed the installation before starting this tutorial.
What You’ll Build
You’ll create an agent that:
- Opens Amazon in a web browser
- Searches for a product
- Verifies the search results
- Generates a report of the automation
Building Your Agent
1
Create Your Agent Script
Create a new Python file amazon_shopping.py
and add the following code:
Run the script:
The script will:
- Open Amazon in your default browser
- Search for “nike shoes”
- Verify the cart contents
- Generate an HTML report of the automation
2
Understanding Your Code
Let’s break down what each part does:
Agent Initialization
- Creates a vision agent that can see and interact with your screen
- Enables debug logging to see what’s happening
- Sets up HTML reporting to review the automation later
Browser Control
- Opens a new browser window with Amazon
- Waits for the page to load
Element Interaction
- Finds and clicks the search box
- Types the search query
- Presses Enter to search
Information Extraction
- Uses AI to understand what’s on the screen
- Returns a natural language response
3
View the Report
After running your agent, open the generated HTML report:
The report shows:
- Screenshots of each step
- Actions performed
- Execution time
- Any errors encountered
Enhancing Your Agent
Try these modifications to learn more:
1. Add Product to Cart
2. Use Different Selectors
3. Extract Product Information
Common Issues and Solutions
Browser doesn't open
Browser doesn't open
- Check if you have a default browser set
- Try using a specific browser path
- Ensure AskUI Agent OS is running
Element not found
Element not found
- Add wait times for dynamic content
- Use more specific locators
- Check if the element is visible on screen
Script runs too fast
Script runs too fast
- Add
agent.wait()
between actions - Enable visual debugging with screenshots
- Use SimpleHTMLReporter
What You’ve Learned
Congratulations! You’ve successfully:
- ✅ Created your first AskUI agent
- ✅ Automated browser interactions
- ✅ Used AI to verify screen content
- ✅ Generated automation reports