Skip to main content

Overview

Automate deal hunting, coupon finding, and even complete purchases to save time and money.

Smart Deal Finder

Find the best deals across multiple retailers.
import { AGIClient } from 'agi';

const client = new AGIClient({ apiKey: 'your_api_key' });
const session = await client.createSession('agi-0');

const maxPrice = 350;
const result = await session.runTask(`
    Find the best deals on: Sony WH-1000XM5 (under $${maxPrice})

    Search across: Amazon, eBay, Walmart, Best Buy, Target, Newegg, B&H Photo, Deal aggregator sites (Slickdeals, DealNews).

    For each option: Retailer name, Current price, Original/list price, Discount percentage, Deal type, Condition, Shipping cost, Total cost, Product URL, Deal expiration, Stock status, User ratings.

    Also include: Coupon codes, Cashback opportunities, Price match policies, Bundle deals, Student/military discounts.

    Return as JSON sorted by total cost (lowest first) with summary: Best overall deal, Best deal for new items only, Fastest shipping option, Best value.
`);

await session.delete();

Coupon & Promo Code Finder

Automatically find and apply coupon codes.
const result = await session.runTask(`
    Find active coupon codes for Best Buy in laptops

    Search: Retailer's official coupon page, RetailMeNot, Honey, Slickdeals, Reddit (r/deals), Retailer's email newsletter/homepage.

    For each coupon: Code, Discount (% off or $ off), Minimum purchase requirement, Exclusions, Expiration date, Verified/tested recently, Success rate, Source URL.

    Return as JSON with retailer, coupons array, stacking_opportunities, best_code.

    Prioritize: Currently active codes, Highest discount value, No minimum purchase, Recently verified.
`);

const bestCode = result.best_code.code;

Automated Deal Monitoring

Monitor for deals and get alerts when price drops.
from datetime import datetime
import time

class DealMonitor:
    def __init__(self, api_key, notification_callback):
        self.api_key = api_key
        self.notification_callback = notification_callback
        self.monitored_products = {}

    def add_product(self, product_name, target_price, retailers=None):
        """Add product to deal monitoring"""
        self.monitored_products[product_name] = {
            'target_price': target_price,
            'retailers': retailers or ["Amazon", "Best Buy", "Walmart"],
            'current_best': None,
            'alert_sent': False
        }

    def check_deals(self):
        """Check for deals on all monitored products"""
        for product_name, config in self.monitored_products.items():
            session_id = create_session(self.api_key, agent_name="agi-0-fast")

            try:
                retailers_str = '\n'.join(f'- {r}' for r in config['retailers'])

                send_message(session_id, f"""
                    Quick price check for: {product_name}

                    Retailers:
                    {retailers_str}

                    For each retailer:
                    - Current price (including any visible coupons/sales)
                    - In stock: yes/no
                    - URL

                    Return JSON array with results.
                """)

                result = wait_for_completion(session_id, timeout=45)

                # Find lowest price
                in_stock_options = [r for r in result if r.get('in_stock')]
                if in_stock_options:
                    best_deal = min(in_stock_options, key=lambda x: x['price'])

                    # Check if price meets target
                    if best_deal['price'] <= config['target_price']:
                        if not config['alert_sent']:
                            self.notification_callback({
                                'product': product_name,
                                'target_price': config['target_price'],
                                'current_price': best_deal['price'],
                                'retailer': best_deal['retailer'],
                                'url': best_deal['url'],
                                'savings': config['target_price'] - best_deal['price']
                            })
                            config['alert_sent'] = True

                    config['current_best'] = best_deal

            finally:
                delete_session(session_id)

    def monitor(self, check_interval=3600):
        """Start monitoring (default: check every hour)"""
        print(f"Monitoring {len(self.monitored_products)} products...")

        while True:
            self.check_deals()
            time.sleep(check_interval)

# Usage
def send_deal_alert(alert_data):
    print(f"🎉 DEAL ALERT: {alert_data['product']}")
    print(f"Target: ${alert_data['target_price']}")
    print(f"Current: ${alert_data['current_price']} at {alert_data['retailer']}")
    print(f"Save ${alert_data['savings']:.2f}!")
    print(f"Buy now: {alert_data['url']}")

monitor = DealMonitor(API_KEY, send_deal_alert)
monitor.add_product("iPad Air M2", target_price=499)
monitor.add_product("AirPods Pro 2", target_price=189)
monitor.monitor(check_interval=1800)  # Check every 30 minutes

Flash Sale Hunter

Monitor for time-limited flash sales.
const categories = ["Electronics", "Home & Garden", "Fashion"];
const retailers = ["Amazon", "Best Buy", "Woot", "TechBargains"];

const result = await session.runTask(`
    Find active flash sales and lightning deals

    Categories: ${categories.join(', ')}
    Retailers: ${retailers.join(', ')}

    For each retailer: Check flash sale/lightning deal sections, Check "Deal of the Day", Check time-limited promotions.

    For each deal: Product name, Category, Original price, Sale price, Discount percentage, Time remaining (countdown), Stock available, Deal URL, Claimed percentage.

    Return as JSON sorted by discount percentage (highest first) with flash_sales array, expiring_soon (deals expiring in < 1 hour), and best_deals (top 5 by discount).
`);

Bundle Deal Finder

Find bundle deals and package savings.
const products = [
    "PlayStation 5",
    "Extra DualSense Controller",
    "Spider-Man 2 Game",
    "PlayStation Plus Subscription"
];

const result = await session.runTask(`
    Find bundle deals that include these products: ${products.join(', ')}

    Search for: Pre-made bundles, "Buy together and save" deals, Multi-buy discounts, Retailer-created bundles, Manufacturer bundles.

    For each bundle: Items included, Bundle price, Individual prices (sum if bought separately), Total savings, Bundle URL, Retailer, Stock status.

    Also calculate: Best combination of bundles to get all items, Optimal purchasing strategy, Maximum possible savings.

    Return as JSON with bundles array and optimal_strategy (bundles_to_buy, total_cost, individual_cost, total_savings, savings_pct).
`);

Cashback & Rewards Maximizer

Find the best cashback and rewards opportunities.
const creditCards = ["Chase Sapphire Reserve", "Amex Gold"];

const result = await session.runTask(`
    Find best cashback opportunities for: MacBook Pro 14-inch

    Consider: Cashback portals (Rakuten, TopCashback, BeFrugal), Credit card rewards: ${creditCards.join(', ')}, Retailer loyalty programs, Browser extensions (Honey, Capital One Shopping), Shopping apps with rewards.

    For each opportunity: Source (portal/card/program), Cashback rate (% or $), Estimated cashback amount, Stacking possible (yes/no), Requirements/minimums, Redemption terms.

    Calculate: Best single source, Best stacking combination, Maximum total cashback possible.

    Return as JSON with opportunities array and best_stack (sources, total_cashback, effective_discount, final_cost).
`);

Automated Checkout

Automate the checkout process (with proper authorization).
async function automatedCheckout(sessionId, productUrl, paymentToken, shippingAddress) {
  // IMPORTANT: Only use with proper authorization and secure payment tokens
  
  const summary = await session.runTask(`
    Complete checkout for product at: ${productUrl}

    Steps:
    1. Navigate to the product page
    2. Click "Add to Cart"
    3. Go to cart
    4. Proceed to checkout
    5. Enter shipping address: ${JSON.stringify(shippingAddress)}
    6. Select fastest available shipping
    7. Apply payment using token: ${paymentToken}
    8. Review order details
    9. STOP and provide order summary for confirmation

    DO NOT complete the purchase yet.

    Return JSON with ready_to_purchase, order_summary (items, subtotal, tax, shipping, total, estimated_delivery), payment_method, shipping_method.

    Wait for explicit confirmation before completing purchase.
  `);

  return summary;
}

async function confirmAndCompletePurchase(sessionId) {
  const result = await session.runTask(`
    User confirmed. Complete the purchase:
    1. Click final "Place Order" or "Complete Purchase" button
    2. Wait for order confirmation
    3. Capture order number
    4. Take screenshot of confirmation page

    Return JSON with order_placed, order_number, confirmation_email, estimated_delivery.
  `);

  return result;
}

// Usage (with user confirmation required)
const summary = await automatedCheckout(
  sessionId,
  "https://www.amazon.com/...",
  "guest_token_123",  // Use secure payment tokens
  {
    name: "John Doe",
    street: "123 Main St",
    city: "San Francisco",
    state: "CA",
    zip: "94102"
  }
);

console.log(`Order Total: $${summary.order_summary.total}`);
console.log(`Delivery: ${summary.order_summary.estimated_delivery}`);

// Get user confirmation
const userConfirms = await getUserInput("Confirm purchase? (yes/no): ");

if (userConfirms.toLowerCase() === 'yes') {
  const result = await confirmAndCompletePurchase(sessionId);
  console.log(`Order #${result.order_number} placed successfully!`);
}
Automated checkout requires explicit user authorization and should use secure payment tokens. Never store or hardcode payment credentials. Always provide order summary and require confirmation before completing purchases.

Deal Aggregator

Aggregate deals from multiple sources into a single feed.
class DealAggregator:
    def __init__(self, api_key):
        self.api_key = api_key

    def get_daily_deals(self, categories=None, min_discount=20):
        """Get aggregated deals from multiple sources"""
        session_id = create_session(self.api_key, agent_name="agi-0")

        categories_str = '\n'.join(f'- {c}' for c in categories) if categories else "All categories"

        send_message(session_id, f"""
            Aggregate today's best deals from multiple sources:

            Sources to check:
            - Slickdeals (front page deals)
            - RedFlagDeals (if applicable)
            - DealNews
            - TechBargains
            - Amazon Gold Box
            - Best Buy Deal of the Day
            - RetailMeNot trending deals

            Filters:
            - Categories: {categories_str}
            - Minimum discount: {min_discount}%
            - Active deals only (not expired)

            For each deal:
            - Product name
            - Category
            - Retailer
            - Original price
            - Deal price
            - Discount percentage
            - Deal type (sale, coupon, rebate, etc.)
            - Upvotes/popularity (if shown)
            - Expiration
            - URL

            Return as JSON sorted by popularity/upvotes:
            {{
                "deals": [...],
                "hot_deals": [...],  // Trending/most popular
                "expiring_soon": [...],  // Expire in < 24 hours
                "categories": {{...}}  // Deals grouped by category
            }}
        """)

        result = wait_for_completion(session_id)
        delete_session(session_id)

        return result

    def get_personalized_deals(self, interests, price_range=None):
        """Get deals personalized to user interests"""
        session_id = create_session(self.api_key, agent_name="agi-0")

        interests_str = '\n'.join(f'- {i}' for i in interests)
        price_str = f"between ${price_range[0]} and ${price_range[1]}" if price_range else "any price"

        send_message(session_id, f"""
            Find personalized deals based on these interests:
            {interests_str}

            Price range: {price_str}

            Search across all deal sites and retailers for products matching these interests.

            Return top 20 deals sorted by relevance and value.
        """)

        result = wait_for_completion(session_id)
        delete_session(session_id)

        return result

# Usage
aggregator = DealAggregator(API_KEY)

# Daily deals in specific categories
deals = aggregator.get_daily_deals(
    categories=["Electronics", "Computers", "Gaming"],
    min_discount=25
)

# Personalized deals
personal_deals = aggregator.get_personalized_deals(
    interests=["Mechanical keyboards", "Gaming monitors", "Productivity software"],
    price_range=(50, 500)
)

Best Practices

Verify Deals

Always verify deal prices and availability before purchasing

Stack Savings

Combine coupons, cashback, and rewards for maximum savings

Secure Payments

Use secure payment tokens and never store credentials

Set Price Alerts

Monitor target prices to catch the best deals