How to Build AI Agents That Connect Multiple APIs for Business Automation
Purpose
I run a small e-commerce business. Every day I jump between Shopify for orders, Stripe for payments, ShipStation for shipping, and Google Ads for marketing. Each platform has its own API, its own data format, and its own authentication. Getting a simple answer like “What’s my ROAS today?” requires logging into four different dashboards.
I needed a way to connect all these APIs together. This post shows how I built AI agents that connect multiple APIs for business automation. The key point is starting with a focused use case and expanding incrementally.
The Problem
Modern businesses use dozens of APIs. Each one requires:
- Separate authentication and credentials
- Understanding different data formats
- Manual data correlation between services
- Technical expertise to integrate
This fragmentation creates silos and slows decision-making. I was spending hours jumping between platforms just to get a complete picture of my operations.
Here’s what a typical morning looked like for me:
1. Log into Shopify -> Export orders to CSV2. Log into Stripe -> Export payment data3. Open Excel -> Combine the CSVs manually4. Log into ShipStation -> Check shipping costs5. Log into Google Ads -> Check ad spend6. Calculate ROAS manually in Excel7. Repeat for inventory predictionsThis process took 45-50 minutes every single day. And it was error-prone. One wrong cell reference in Excel and my calculations were off.
What I Tried First
I looked at custom integrations. Building a custom dashboard seemed like the obvious solution. But I quickly ran into problems:
# This approach didn't scaleimport shopifyimport stripeimport shipstation
# Each API has different authenticationshopify_client = shopify.Client(api_key="...", password="...")stripe_client = stripe.Client(api_key="...")shipstation_client = shipstation.Client(api_key="...", secret="...")
# Each API returns data in different formatsorders = shopify_client.orders.list() # Returns nested dictpayments = stripe_client.charges.list() # Returns list of objectsshipping = shipstation_client.orders.list() # Returns different structure
# Now I need to normalize everything# And handle rate limits# And retry on failures# And keep credentials secure# And... this is getting complicatedI gave up after two weeks. The maintenance burden was too high.
The Solution: AI Agent Orchestration
Then I discovered AI agent orchestration platforms. These platforms let you connect APIs conversationally, without writing custom integration code.
Step 1: Choose an Orchestration Platform
I tested several options:
| Platform | Type | Best For |
|---|---|---|
| OpenClaw | Code-based | Lightweight custom workflows |
| n8n | No-code | Visual workflow automation |
| LangChain | Code-based | Complex agent development |
| Claude Desktop | No-code | Quick prototyping |
I chose OpenClaw for its simplicity. Here’s how I set it up:
# Install OpenClawpip install openclaw
# Or use n8n for no-code approachnpm install -g n8nStep 2: Authenticate Your APIs
I started with my three most critical services:
import osfrom openclaw import Agent, Tool
# Secure credential managementSHOPIFY_API_KEY = os.environ.get("SHOPIFY_API_KEY")STRIPE_API_KEY = os.environ.get("STRIPE_API_KEY")SHIPSTATION_API_KEY = os.environ.get("SHIPSTATION_API_KEY")
# Never hardcode credentials like this:# SHOPIFY_API_KEY = "sk_live_abc123..." # WRONG!
# Create API tools@Tooldef get_shopify_orders(days: int = 7) -> list: """Fetch orders from Shopify for the last N days""" # Implementation here pass
@Tooldef get_stripe_charges(days: int = 7) -> list: """Fetch charges from Stripe for the last N days""" # Implementation here pass
@Tooldef get_shipping_costs(order_ids: list) -> dict: """Get shipping costs for specific orders""" # Implementation here passStep 3: Define Your Workflows
I mapped out my most common tasks:
Data Aggregation: - Pull orders from multiple channels into one view - Calculate total revenue across platforms
Cross-Reference: - Match inventory with sales velocity - Predict stockouts before they happen
Action Chains: - Order placed -> Update inventory -> Create label -> Send confirmation
Reporting: - Combine ads spend, sales, and costs - Calculate true ROASStep 4: Test with Conversational Queries
The power of AI agents is natural language interaction. I tested queries like:
from openclaw import Agent
agent = Agent( tools=[get_shopify_orders, get_stripe_charges, get_shipping_costs], model="gpt-4")
# Natural language queriesresponse1 = agent.run("Show me all orders from the last 7 days and calculate total revenue")response2 = agent.run("Which products are running low on inventory based on current sales rate?")response3 = agent.run("What's my ROAS for Google Ads campaigns this week?")The agent figured out which APIs to call, how to combine the data, and returned clear answers.
Step 5: Build Custom Tools for Repeated Workflows
For workflows I run daily, I created dedicated tools:
from openclaw import Agent, Toolfrom typing import TypedDict
class OrderSummary(TypedDict): total_orders: int total_revenue: float shipping_cost: float profit: float
@Tooldef calculate_daily_summary() -> OrderSummary: """Calculate daily business summary across all platforms""" orders = get_shopify_orders(days=1) charges = get_stripe_charges(days=1) shipping = get_shipping_costs([o["id"] for o in orders])
total_revenue = sum(o["total"] for o in orders) shipping_cost = sum(s["cost"] for s in shipping.values())
return { "total_orders": len(orders), "total_revenue": total_revenue, "shipping_cost": shipping_cost, "profit": total_revenue - shipping_cost }
# Create specialized agentbusiness_agent = Agent( name="operations_hub", tools=[calculate_daily_summary, get_shopify_orders, get_stripe_charges], model="gpt-4")
# Morning routine - now takes 30 seconds instead of 45 minutessummary = business_agent.run("Give me today's business summary")print(summary)Real Results
After implementing this approach, here’s what changed:
Time Savings: My 45-50 minute morning routine now takes 2-3 minutes.
Accuracy: No more copy-paste errors when transferring data between systems.
Accessibility: My non-technical co-founder can now query our systems using natural language.
Scalability: Once built, workflows run infinitely without additional human effort.
Common Mistakes I Made
Mistake 1: Trying to Connect Too Many APIs at Once
I started by trying to connect 8 APIs simultaneously. The complexity was overwhelming.
Solution: Start with 2-3 APIs. Get one workflow working perfectly, then expand.
Mistake 2: Ignoring Rate Limits
# WRONG: No rate limitingfor order in all_orders: shipping = get_shipping_cost(order.id) # Will hit rate limits!
# RIGHT: Batch operationsorder_ids = [o.id for o in all_orders]shipping_costs = get_shipping_costs(order_ids) # Single API callAPIs have usage limits. Batch operations and cache responses appropriately.
Mistake 3: Hardcoding API Keys
# NEVER do thisAPI_KEY = "sk_live_abc123xyz..." # Will be committed to git!
# Always use environment variablesAPI_KEY = os.environ.get("SHOPIFY_API_KEY")if not API_KEY: raise ValueError("SHOPIFY_API_KEY not configured")Mistake 4: Assuming APIs Will Always Be Available
Build retry logic and graceful degradation:
import timefrom functools import wraps
def retry_on_failure(max_retries=3, delay=1): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): for attempt in range(max_retries): try: return func(*args, **kwargs) except Exception as e: if attempt == max_retries - 1: raise time.sleep(delay * (attempt + 1)) return None return wrapper return decorator
@retry_on_failure(max_retries=3, delay=2)def fetch_orders(): # API call with automatic retry passMistake 5: Overcomplicating Queries
Start with simple natural language requests and build complexity gradually:
# Start simpleagent.run("Show orders from yesterday")
# Then add complexityagent.run("Show orders from yesterday with revenue > $100")
# Finally, complex queriesagent.run("Show orders from yesterday with revenue > $100, calculate shipping costs, and predict inventory needs")Best Practices I Learned
- Start small with 2-3 APIs before expanding
- Use read-only operations first, add write operations after testing
- Set up proper error handling and logging from day one
- Monitor API rate limits and costs regularly
- Keep credentials secure and rotated regularly
Summary
In this post, I showed how I built AI agents that connect multiple APIs for business automation. The key point is starting with a focused use case and expanding incrementally.
I went from spending 45-50 minutes daily on manual data gathering to 2-3 minutes with AI agent orchestration. The approach works because:
- AI agents handle the complexity of different API formats
- Natural language queries make the system accessible to non-technical users
- Workflows can be built incrementally without overwhelming complexity
Start with your most painful daily task. Connect 2-3 APIs that would solve it. Build one workflow. Then expand from there.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 OpenClaw
- 👨💻 LangChain Documentation
- 👨💻 n8n Workflow Automation
- 👨💻 Model Context Protocol
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments