Skip to content

Rohit1419/business-agent

Repository files navigation

Business Operations Agent

An autonomous agent powered by ReAct (Reason-Act) loop that automates local business reputation management. The agent monitors reviews, responds to customers, and generates weekly performance insights.

Setup

Prerequisites

  • Python 3.8+
  • Active MEWCP account with Business & Gmail credentials
  • OpenRouter API key

Installation

  1. Clone or navigate to the project directory:

    cd business-agent
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure environment variables:

    cp .env.example .env
    # Edit .env with your credentials

Environment Variables

See .env.example for all required variables:

Google Business MCP Service:

  • BUSINESS_MCP_API_KEY: API key for Google Business MCP service
  • BUSINESS_CREDENTIAL_ID: Google Business credential ID

Gmail MCP Service:

  • GMAIL_MCP_API_KEY: API key for Gmail MCP service
  • GMAIL_CREDENTIAL_ID: Gmail credential ID

LLM Provider:

  • OPENROUTER_API_KEY: OpenRouter API key for LLM access

Usage

Basic Execution

python main.py

The agent will:

  1. Get review summary for the location
  2. Fetch unanswered reviews
  3. Reply to each review individually
  4. Pull weekly performance insights
  5. Send a digest email to the owner
  6. Output step-by-step reasoning and results

Configuration

Edit config.py to customize:

  • Model Selection: Change MODEL to use different LLM providers:
    MODEL = "anthropic/claude-sonnet-4-6"  # or openai/gpt-4o-mini, etc.
  • Max Steps: Adjust MAX_STEPS to control maximum iterations
  • API Timeouts: Modify LLM_TIMEOUT for HTTP requests

Running with Custom Parameters

Edit main.py and update the run_agent() call:

await run_agent(
    location_name="accounts/YOUR_ACCOUNT_ID/locations/YOUR_LOCATION_ID",
    owner_email="owner@yourbusiness.com",
)

How It Works

ReAct Pattern

┌─ Observe ──────────────────────────────────────┐
│ Current state: reviews, insights, progress     │
├─ Reason ───────────────────────────────────────┤
│ LLM decides next action (decide function)      │
├─ Act ──────────────────────────────────────────┤
│ Execute tool via fastMCP                       │
├─ Reflect ──────────────────────────────────────┤
│ LLM analyzes result (reflect function)         │
├─ Update ──────────────────────────────────────┤
│ State manager tracks progress                  │
└─ Loop (until done or max steps reached) ───────┘

State Tracking

The agent maintains state including:

  • location_name: Business location
  • owner_email: Email recipient
  • review_stats: Summary of reviews
  • unanswered_reviews: List of reviews needing replies
  • replied_reviews: Tracking of completed replies
  • insights: Weekly performance metrics
  • actions_taken: History of executed actions

Available Tools

Tool Purpose
get_review_summary Get total reviews, avg rating, reply rate, distribution
list_reviews Fetch recent reviews (can filter by rating)
reply_to_review Post reply to individual review
get_insights Pull weekly metrics (views, clicks, directions)
send_message Send digest email to owner

Logs & Output

The agent prints step-by-step progress:

============================================================
Business Operations Agent  |  model: google/gemini-2.5-flash
Location : accounts/123456789/locations/987654321
Owner    : owner@yourbusiness.com
============================================================

── Step 1 ────────────────────────────────────────────────
  Thought : I should start by getting a summary of reviews...
  Action  : get_review_summary  {...}
  Result  : {'total_reviews': 42, 'avg_rating': 4.5, ...}
  Reflect : Good progress. Now I need to list reviews...

[...]

============================================================
Done — 5 steps | 3 replies sent
============================================================

Troubleshooting

Missing Environment Variables

KeyError: 'BUSINESS_MCP_API_KEY'

Solution: Create .env file with all required variables (see .env.example). Make sure both BUSINESS_MCP_API_KEY and GMAIL_MCP_API_KEY are set.

Connection Errors

httpx.ConnectError: Unable to connect to gateway.mewcp.com

Solution: Verify MEWCP credentials and API key validity

LLM Rate Limiting

openrouter.ai 429 Too Many Requests

Solution: Increase LLM_TIMEOUT in config.py or reduce MAX_STEPS

Development

Adding a New Tool

  1. Add tool to BUSINESS_TOOLS or GMAIL_TOOLS in tools.py
  2. Add tool specification to TOOLS_SPEC in tools.py
  3. Update update_state() in state.py if state changes are needed
  4. Tool execution is automatic via executor.py

Modifying the System Prompt

Edit SYSTEM_PROMPT in prompts.py to change agent behavior, rules, or execution order.

Support

For issues or questions, refer to:

About

A Google Business agent which handles business operations for you on weekly basis and mail reports on weekly basis.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages