Back to articles
Tutorial

Build Your Own WhatsApp Email Assistant with OpenClaw in 30 Minutes

Step-by-step tutorial to create an AI email assistant that sends summaries to your WhatsApp. No coding. Just configuration. Live example with source code.

14 min read

What We're Building

An AI agent that:

1. Checks your email every 30 minutes

2. Summarizes important messages

3. Sends summary to your WhatsApp

4. Allows you to reply via WhatsApp

5. Agent sends email reply automatically

No coding. No servers. Just configuration.

Prerequisites

  • OpenClaw installed (`pip install openclaw`)
  • OpenAI API key (ChatGPT)
  • WhatsApp Business Account (free tier OK)
  • Gmail account with App Password
  • 30 minutes
  • Step 1: Get Your API Keys

    OpenAI API Key

    1. Go to platform.openai.com/api-keys

    2. Create new secret key

    3. Copy it somewhere safe

    Gmail App Password

    1. Go to myaccount.google.com/security

    2. Enable 2-factor authentication

    3. Generate App Password for Gmail

    4. Copy the 16-character password

    WhatsApp Business API

    1. Go to developers.facebook.com

    2. Create app > WhatsApp

    3. Generate access token

    4. Note your Business Phone ID

    Step 2: Create Configuration File

    Create `email-assistant.yaml`:

    # AI Model Configuration
    model:
      provider: openai
      api_key: ${OPENAI_API_KEY}
      model: gpt-4o
      temperature: 0.7
    
    # Agent Configuration
    agent:
      name: EmailAssistant
      description: "Personal email management agent that monitors inbox and sends summaries"
      
    # Tools the agent can use
    tools:
      - name: fetch_emails
        description: "Retrieve recent emails from inbox"
        config:
          email: ${GMAIL_EMAIL}
          app_password: ${GMAIL_APP_PASSWORD}
      
      - name: summarize_email
        description: "Create concise summary of email content"
      
      - name: send_whatsapp
        description: "Send message via WhatsApp"
        config:
          business_phone_id: ${WHATSAPP_BUSINESS_PHONE_ID}
          access_token: ${WHATSAPP_ACCESS_TOKEN}
      
      - name: send_email_reply
        description: "Send reply to email"
        config:
          email: ${GMAIL_EMAIL}
          app_password: ${GMAIL_APP_PASSWORD}
    
    # Messaging Platform
    platforms:
      - type: whatsapp
        business_phone_id: ${WHATSAPP_BUSINESS_PHONE_ID}
        access_token: ${WHATSAPP_ACCESS_TOKEN}
        your_whatsapp_number: ${YOUR_WHATSAPP_NUMBER}
    
    # Scheduling
    schedules:
      - name: check_email
        trigger: "every 30 minutes"
        action: "fetch_emails"

    Step 3: Set Environment Variables

    Create `.env` file:

    # OpenAI
    export OPENAI_API_KEY="sk-..."
    
    # Gmail
    export GMAIL_EMAIL="your-email@gmail.com"
    export GMAIL_APP_PASSWORD="abcd efgh ijkl mnop"
    
    # WhatsApp
    export WHATSAPP_BUSINESS_PHONE_ID="123456789..."
    export WHATSAPP_ACCESS_TOKEN="EAADk..."
    export YOUR_WHATSAPP_NUMBER="1234567890"

    Load it:

    source .env

    Step 4: Define Agent Behavior

    Create `agent-prompt.txt`:

    You are an email assistant. Your job:
    
    1. Every 30 minutes, fetch the last 10 emails from inbox
    2. Identify important ones (from boss, urgent, new clients)
    3. Create a concise summary:
       - Sender name
       - Subject line
       - 1-2 sentence summary
       - Action required (yes/no)
    4. Send summary to WhatsApp
    5. Wait for user reply
    6. If user asks you to reply to email, compose and send reply
    
    Be concise. No fluff. Time is valuable.

    Step 5: Launch the Agent

    openclaw run email-assistant.yaml --prompt-file agent-prompt.txt

    Output:

    ✓ Agent started: EmailAssistant
    ✓ Connected to WhatsApp
    ✓ Email monitoring active
    ✓ Listening for commands...

    Agent is now running.

    Step 6: Test It

    1. Send email to your address (from another account)

    2. Wait 30 seconds (or manually trigger: "@agent check email")

    3. Check WhatsApp

    4. You receive summary:

    📧 Email Summary:
    
    From: John Smith (boss)
    Subject: Q2 Budget Review
    
    Needs your approval on budget allocation for Q2. $500k marketing, $200k engineering.
    
    Action: Yes - needs reply

    You reply: "Approved. Let's discuss details tomorrow."

    Agent automatically sends email reply to John.

    Advanced Configuration

    Multi-Email Account Support

    tools:
      - name: fetch_emails
        configs:
          - name: work_email
            email: ${WORK_EMAIL}
            app_password: ${WORK_APP_PASSWORD}
          
          - name: personal_email
            email: ${PERSONAL_EMAIL}
            app_password: ${PERSONAL_APP_PASSWORD}

    Custom Summarization Rules

    summarization:
      priority_keywords:
        - urgent
        - important
        - approve
        - deadline
      
      ignore_from:
        - newsletter@*
        - notifications@*
      
      max_summary_length: 100  # characters

    Multiple Notification Channels

    platforms:
      - type: whatsapp
        # WhatsApp config
      
      - type: telegram
        bot_token: ${TELEGRAM_BOT_TOKEN}
      
      - type: slack
        webhook_url: ${SLACK_WEBHOOK}

    Troubleshooting

    Problem: "Cannot connect to WhatsApp"

    Solution:

    1. Check access token is valid

    2. Verify Business Phone ID

    3. Ensure app is approved by Meta

    Problem: "Emails not fetching"

    Solution:

    1. Verify Gmail App Password (not account password)

    2. Check 2FA is enabled

    3. Test connection: `openclaw test-email-connection`

    Problem: "Agent not responding"

    Solution:

    1. Check OpenAI API quota

    2. Verify internet connection

    3. Check agent logs: `openclaw logs email-assistant`

    Cost Analysis

    One month (30 days):

  • OpenAI API: ~$5 (50k tokens @ $0.0001)
  • WhatsApp: ~$0.24 (30 messages @ $0.0079)
  • Gmail: Free
  • Total: ~$5.24/month
  • Sounds expensive? Compare to:

  • Virtual assistant: $500-2000/month
  • Email management service: $100-300/month
  • OpenClaw: $5.24 for similar functionality

    Extension Ideas

    Add Sentiment Analysis

    Agent rates email sentiment (positive, negative, neutral) and alerts you to angry customers.

    Add Calendar Integration

    Agent checks calendar, only notifies about emails related to upcoming meetings.

    Add Database Logging

    All emails logged to database for analytics and future reference.

    Add CRM Integration

    Agent updates CRM with customer emails automatically.

    Security Considerations

    Do:

  • Use App Passwords (not account password)
  • Store API keys in `.env` file
  • Never commit `.env` to Git
  • Use environment variable secrets in production
  • Enable WhatsApp Business verification
  • Don't:

  • Hardcode secrets in YAML
  • Share API keys
  • Run on shared machines
  • Allow agent to delete emails
  • Skip HTTPS for API calls
  • Performance Tips

    1. Increase email check interval if costs get high

    - From every 30 min → every 60 min

    - Cuts costs in half

    2. Filter emails before summarization

    - Only summarize flagged/important emails

    - Reduces processing time

    3. Use cheaper model if acceptable

    - ChatGPT: $0.0001/1k tokens

    - Claude: $0.0003/1k tokens

    - Local Ollama: Free (but slower)

    4. Batch email checks

    - Check once per hour instead of every 30 min

    - Reduces costs by 50%

    Next Steps

    1. Complete this tutorial (30 min)

    2. Add 2nd platform (Telegram, Slack)

    3. Add more tools (calendar, CRM, database)

    4. Build a second agent for different task

    5. Orchestrate multiple agents

    Conclusion

    You now have a personal AI email assistant.

    No coding. No servers. Just configuration.

    This same pattern works for:

  • Customer support
  • Social media management
  • Research automation
  • Lead management
  • And much more
  • OpenClaw makes it possible for anyone to build AI agents.

    Your turn: Build something cool.

    Found this helpful?Share this article with your network to help others discover useful AI insights.