How to Create an OpenClaw Agent
Complete step-by-step guide to building your first AI agent from scratch
What You'll Build
By the end of this guide, you'll have a fully functional OpenClaw agent that can:
- • Read and respond to emails automatically
- • Schedule meetings by checking your calendar
- • Answer common questions using your knowledge base
- • Escalate complex issues to you when needed
Prerequisites
- • A computer with internet connection
- • Basic familiarity with the command line
- • A Gmail or Google Workspace account
- • An OpenAI or Anthropic API key
- • $25 for professional setup (or DIY for free)
Step 1: Choose Your Deployment Method
You have two options for creating your OpenClaw agent:
Option A: Professional Setup
We handle the technical setup for you. Best for busy professionals who want it done right the first time.
- • 48-hour turnaround
- • Secure cloud deployment
- • Custom configuration
- • 30 days support included
Option B: DIY Setup
Follow this guide to set up OpenClaw yourself. Great for learning and complete control.
- • 2-4 hours of setup time
- • Requires technical knowledge
- • Full control over configuration
- • Community support available
Step 2: Set Up Your Server
OpenClaw needs a server to run 24/7. We'll use DigitalOcean for this tutorial (sign up with our link for $450 free credit).
Create a Droplet:
- Sign up at DigitalOcean (or use AWS, GCP, or Azure)
- Click "Create Droplet"
- Choose Ubuntu 22.04 LTS
- Select "Basic" plan with 2GB RAM / 1 CPU ($12/month)
- Choose a datacenter region close to you
- Add SSH key (or use password)
- Click "Create"
Connect to your server:
ssh root@your-server-ip
cd ~Step 3: Install OpenClaw
Run these commands on your server to install OpenClaw:
# Update system
apt update && apt upgrade -y
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
# Install Docker Compose
apt install docker-compose -y
# Clone OpenClaw repository
git clone https://github.com/cline/cline.git openclaw
cd openclaw
# Create environment file
cp .env.example .env
# Edit the .env file with your API keys
nano .envStep 4: Configure Your Agent
Create your agent configuration file. This tells OpenClaw what to do and how to behave.
# Create configuration directory
mkdir -p ~/.openclaw
# Create config.yaml
cat > ~/.openclaw/config.yaml << 'EOF'
# Agent Identity
name: "Business Assistant"
personality: professional, helpful, concise
# AI Model Configuration
model:
provider: anthropic
model: claude-3-5-sonnet-20241022
max_tokens: 4096
temperature: 0.7
# Skills Configuration
skills:
# Email Management
gmail:
enabled: true
credentials_path: /opt/openclaw/gmail-credentials.json
auto_reply: false # Set to true after testing
auto_archive: true
# Calendar
google_calendar:
enabled: true
credentials_path: /opt/openclaw/calendar-credentials.json
# Web Search
web_search:
enabled: true
provider: brave
api_key: ${BRAVE_API_KEY}
# Memory & Learning
memory:
enabled: true
store_path: /opt/openclaw/memory
# Logging
logging:
level: info
file: /var/log/openclaw/agent.log
EOFStep 5: Set Up Gmail Integration
Your agent needs access to read and send emails. Here's how to set up Gmail securely:
Create Gmail Credentials:
- 1. Go to Google Cloud Console
- 2. Create a new project (or select existing)
- 3. Enable the Gmail API: APIs & Services → Library → Gmail API → Enable
- 4. Create credentials: APIs & Services → Credentials → Create Credentials → OAuth 2.0 Client ID
- 5. Configure OAuth consent screen (External)
- 6. Add scope:
https://www.googleapis.com/auth/gmail.modify - 7. Download the JSON file and save as
gmail-credentials.json - 8. Upload to your server:
/opt/openclaw/
First-time authentication:
# Run authentication script
docker-compose run --rm openclaw python /app/auth/gmail.py
# This will output a URL. Open it in your browser and authorize access.
# Copy the authorization code back to the terminal.Step 6: Create Your First Prompt
Prompts tell your agent how to handle specific situations. Let's create a customer support prompt:
# Create prompts directory
mkdir -p ~/.openclaw/prompts
# Create customer support prompt
cat > ~/.openclaw/prompts/customer_support.txt << 'EOF'
You are a helpful customer support assistant for [Your Business Name].
Your responsibilities:
1. Answer common questions about our products/services
2. Check order status when customers ask
3. Handle refund requests according to policy (30-day returns)
4. Escalate complex issues to human support
Response guidelines:
- Be friendly and professional
- Answer within 2-3 sentences when possible
- Always offer further assistance
- If unsure, say "Let me connect you with a team member"
Our business details:
- Business hours: Monday-Friday 9AM-6PM EST
- Return policy: 30 days with receipt
- Contact phone: (555) 123-4567
- Website: www.yourbusiness.com
Knowledge base location: /opt/openclaw/knowledge/
EOFStep 7: Start Your Agent
Now it's time to launch your agent:
# Start OpenClaw with Docker
docker-compose up -d
# Check logs
docker-compose logs -f
# Verify it's running
curl http://localhost:3000/health
# You should see: {"status": "healthy"}🎉 Success! Your agent is now running and monitoring your email. It will start processing new messages immediately.
Step 8: Test and Refine
Before going live, thoroughly test your agent:
Testing Checklist:
- ☐ Send a test email and verify agent receives it
- ☐ Check that responses are appropriate and helpful
- ☐ Verify calendar integration works
- ☐ Test escalation for complex queries
- ☐ Review first 10 responses before enabling auto-reply
- ☐ Set up monitoring alerts for errors
Enable auto-reply (after testing):
# Edit config
nano ~/.openclaw/config.yaml
# Change:
# auto_reply: false
# to:
# auto_reply: true
# Restart agent
docker-compose restartCommon Issues & Solutions
Agent not receiving emails
Check Gmail API credentials, verify OAuth consent screen is published (not in testing mode), and ensure the credentials file path is correct in config.yaml.
API rate limit errors
Add rate limiting to your config. Most APIs allow 60 requests/minute. Consider upgrading your API plan if you hit limits regularly.
Agent responses are off-topic
Refine your prompts to be more specific. Add examples of good responses. Update your knowledge base with more relevant information.
Next Steps: Expand Your Agent
Add More Skills
- • Slack integration
- • CRM connection (HubSpot, Salesforce)
- • Calendar management
- • Web scraping
Advanced Features
- • Custom API integrations
- • Multi-agent workflows
- • Advanced prompt engineering
- • Analytics and reporting
Related Articles
Need Help Creating Your Agent?
Skip the technical setup. We'll create and configure your OpenClaw agent professionally. $25 one-time fee. 48-hour delivery. 30 days of support included.
Get Professional Setup →