Skip to main content
Enable Agno agents with Shopify tools to:
  • Analyze sales data and identify top-selling products
  • Find products that are frequently bought together
  • Track inventory levels and identify low-stock items
  • Generate sales reports and trends
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.shopify import ShopifyTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


sales_agent = Agent(
    name="Sales Analyst",
    model=OpenAIChat(id="gpt-4o"),
    tools=[ShopifyTools()],
    instructions=[
        "You are a sales analyst for an e-commerce store using Shopify.",
        "Help the user understand their sales performance, product trends, and customer behavior.",
        "When analyzing data:",
        "1. Start by getting the relevant data using the available tools",
        "2. Summarize key insights in a clear, actionable format",
        "3. Highlight notable patterns or concerns",
        "4. Suggest next steps when appropriate",
        "Always present numbers clearly and use comparisons to add context.",
        "If you need to get information about the store, like currency, call the `get_shop_info` tool.",
    ],
    add_datetime_to_context=True,
    markdown=True,
)

# Example usage
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    # Example 1: Get top selling products
    sales_agent.print_response(
        "What are my top 5 selling products in the last 30 days? "
        "Show me quantity sold and revenue for each.",
    )

    # Example 2: Products bought together
    sales_agent.print_response(
        "Which products are frequently bought together? "
        "I want to create product bundles for my store."
    )

    # Example 3: Sales trends
    sales_agent.print_response(
        "How are my sales trending compared over the last 3 months? "
        "Are we up or down in terms of revenue and order count?"
    )

Run the Example

# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools

# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate

python shopify_tools.py
For details, see Shopify tools cookbook.