{
  "schemaVersion": "1.0",
  "item": {
    "slug": "whatsapp-context-manager",
    "name": "Whatsapp Context Manager for Agents",
    "source": "tencent",
    "type": "skill",
    "category": "通讯协作",
    "sourceUrl": "https://clawhub.ai/cerbug45/whatsapp-context-manager",
    "canonicalUrl": "https://clawhub.ai/cerbug45/whatsapp-context-manager",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/whatsapp-context-manager",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=whatsapp-context-manager",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "README.md",
      "SKILL.md",
      "examples_whatsapp.py",
      "install_check_whatsapp.py",
      "requirements_whatsapp.txt",
      "test_whatsapp.py"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/whatsapp-context-manager"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/whatsapp-context-manager",
    "agentPageUrl": "https://openagent3.xyz/skills/whatsapp-context-manager/agent",
    "manifestUrl": "https://openagent3.xyz/skills/whatsapp-context-manager/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/whatsapp-context-manager/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "WhatsApp Intelligent Context Manager - Skill Guide",
        "body": "This skill provides an AI-powered context management system for WhatsApp customer service agents, enabling instant access to customer history, sentiment analysis, and smart response suggestions."
      },
      {
        "title": "Quick Installation",
        "body": "# Download and extract\nunzip whatsapp-context-manager.zip\ncd whatsapp-context-manager\n\n# Verify installation (no dependencies needed!)\npython install_check_whatsapp.py\n\n# Run tests\npython test_whatsapp.py\n\n# Try examples\npython examples_whatsapp.py"
      },
      {
        "title": "What Problem Does This Solve?",
        "body": "Without This System:\n\n❌ Agents have no context when customer messages arrive\n❌ No idea if customer is VIP or first-timer\n❌ Can't see order status without switching systems\n❌ Don't know if message is urgent or can wait\n❌ Guessing what to say instead of smart suggestions\n\nWith This System:\n\n✅ Complete customer context in 2 seconds\n✅ Automatic sentiment analysis (angry/happy/neutral)\n✅ Smart priority (critical/high/normal/low)\n✅ Order status right there\n✅ AI-powered response suggestions\n✅ VIP customer detection"
      },
      {
        "title": "1. Initialize the System",
        "body": "from whatsapp_context_manager import ContextManager\n\n# Create context manager (creates local database)\nmanager = ContextManager(\"production.db\")"
      },
      {
        "title": "2. Process Incoming WhatsApp Message",
        "body": "# When a WhatsApp message arrives\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"Where is my order?!\",\n    agent_id=\"agent_001\"\n)"
      },
      {
        "title": "3. Display Context to Agent",
        "body": "# Show agent what they need to know\nprint(f\"Priority: {context.priority.value}\")        # \"critical\"\nprint(f\"Sentiment: {context.sentiment.value}\")      # \"negative\"\nprint(f\"Category: {context.category}\")              # \"order_status\"\nprint(f\"VIP Customer: {context.customer.is_vip}\")   # True/False\n\n# Key insights\nfor insight in context.key_insights:\n    print(f\"💡 {insight}\")\n\n# Warnings\nfor warning in context.warnings:\n    print(f\"⚠️ {warning}\")\n\n# Suggested responses\nfor response in context.suggested_responses:\n    print(f\"💬 {response}\")"
      },
      {
        "title": "4. Send Reply",
        "body": "# Agent sends reply\nmanager.send_message(\n    phone=\"+1234567890\",\n    message_content=\"Your order #12345 is on the way!\",\n    agent_id=\"agent_001\"\n)"
      },
      {
        "title": "What Agent Sees - Dashboard Example",
        "body": "┌──────────────────────────────────────────────────────┐\n│                  AGENT DASHBOARD                     │\n├──────────────────────────────────────────────────────┤\n│ Customer: +1234567890                                │\n│ Name: John Doe                                       │\n│ VIP: YES                                             │\n├──────────────────────────────────────────────────────┤\n│ Priority: CRITICAL                                   │\n│ Sentiment: NEGATIVE                                  │\n│ Category: ORDER_STATUS                               │\n├──────────────────────────────────────────────────────┤\n│ KEY INSIGHTS:                                        │\n│   • 🌟 VIP Customer - Prioritize response            │\n│   • 📦 Active Order: #ORD-12345 - shipped            │\n│   • 🚚 Tracking: TRK-ABC123                          │\n│   • ⚡ Customer expects fast replies (~2min)         │\n├──────────────────────────────────────────────────────┤\n│ WARNINGS:                                            │\n│   • 🚨 CRITICAL: Requires immediate attention!       │\n│   • 😡 Customer is very upset - handle with care     │\n├──────────────────────────────────────────────────────┤\n│ SUGGESTED RESPONSES:                                 │\n│   1. Let me check your order status right away.     │\n│   2. Your order #ORD-12345 is shipped.               │\n└──────────────────────────────────────────────────────┘"
      },
      {
        "title": "1. Automatic Sentiment Analysis",
        "body": "Detects customer mood from message:\n\n# System automatically analyzes sentiment\ncontext = manager.process_incoming_message(phone, \"This is TERRIBLE!\", agent_id)\nprint(context.sentiment.value)  # \"very_negative\"\n\ncontext = manager.process_incoming_message(phone, \"Thanks!\", agent_id)\nprint(context.sentiment.value)  # \"positive\"\n\nSentiment Levels:\n\n😡 very_negative - Angry, furious, scam\n😟 negative - Disappointed, problem\n😐 neutral - Questions, info requests\n😊 positive - Thanks, happy\n🤩 very_positive - Excellent, love it"
      },
      {
        "title": "2. Message Categorization",
        "body": "Automatically categorizes messages:\n\n# System automatically categorizes\ncontext = manager.process_incoming_message(phone, \"Where is my package?\", agent_id)\nprint(context.category)  # MessageCategory.ORDER_STATUS\n\ncontext = manager.process_incoming_message(phone, \"Refund please!\", agent_id)\nprint(context.category)  # MessageCategory.PAYMENT\n\nCategories:\n\n📦 ORDER_STATUS - Delivery, tracking, shipment\n💳 PAYMENT - Refund, billing, transaction\n🔴 COMPLAINT - Problem, issue, broken\n🛍️ PRODUCT_INQUIRY - Price, stock, features\n🆘 SUPPORT - Help, how-to, questions\n💰 SALES - Buy, purchase, interested\n⭐ FEEDBACK - Review, opinion\n❓ OTHER - Uncategorized"
      },
      {
        "title": "3. Priority Calculation",
        "body": "Smart priority based on multiple factors:\n\n# System calculates priority\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"My payment failed!!!\",\n    agent_id=\"agent_001\"\n)\nprint(context.priority.value)  # \"critical\"\n\nPriority Levels:\n\n🔴 CRITICAL - Angry customer, payment issue, VIP unhappy\n🟠 HIGH - Complaints, negative sentiment\n🟡 NORMAL - General questions\n🟢 LOW - Info requests, positive feedback"
      },
      {
        "title": "4. Response Suggestions",
        "body": "AI suggests appropriate responses:\n\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"When will my order arrive?\",\n    agent_id=\"agent_001\"\n)\n\n# Get suggestions\nfor response in context.suggested_responses:\n    print(response)\n# Output:\n# \"Let me check your order status right away.\"\n# \"Your order #12345 is currently shipped.\"\n# \"Expected delivery is tomorrow.\""
      },
      {
        "title": "Order Integration",
        "body": "Add and track customer orders:\n\nfrom whatsapp_context_manager import Order\nfrom datetime import datetime, timedelta\n\n# Add order to system\norder = Order(\n    order_id=\"ORD-12345\",\n    customer_id=context.customer.customer_id,\n    status=\"shipped\",\n    amount=99.99,\n    items=[\n        {\"name\": \"Wireless Headphones\", \"quantity\": 1, \"price\": 99.99}\n    ],\n    created_at=datetime.now().isoformat(),\n    updated_at=datetime.now().isoformat(),\n    tracking_number=\"TRK-ABC123\",\n    estimated_delivery=(datetime.now() + timedelta(days=2)).strftime(\"%Y-%m-%d\")\n)\n\nmanager.add_order(order)\n\n# Now when customer asks about order, agent sees all details\ncontext = manager.process_incoming_message(phone, \"Order status?\", agent_id)\nprint(context.active_orders[0].tracking_number)  # \"TRK-ABC123\""
      },
      {
        "title": "VIP Customer Management",
        "body": "Mark and manage VIP customers:\n\n# Update customer to VIP\nmanager.update_customer_info(\n    phone=\"+1234567890\",\n    name=\"John Doe\",\n    email=\"john@example.com\",\n    is_vip=True,\n    tags=[\"premium\", \"loyal\", \"high-value\"],\n    notes=\"Always responds best to quick, direct answers\"\n)\n\n# Future messages automatically show VIP status\ncontext = manager.process_incoming_message(phone, \"Hello\", agent_id)\nprint(context.customer.is_vip)  # True\nprint(context.customer.tags)    # [\"premium\", \"loyal\", \"high-value\"]"
      },
      {
        "title": "Conversation History",
        "body": "Access complete conversation history:\n\n# Get context (includes recent messages)\ncontext = manager.process_incoming_message(phone, \"Need help\", agent_id)\n\n# View recent messages\nfor msg in context.recent_messages:\n    direction = \"Customer\" if msg.direction == \"inbound\" else \"Agent\"\n    print(f\"{direction}: {msg.content}\")"
      },
      {
        "title": "Customer Profile",
        "body": "Access complete customer profile:\n\ncontext = manager.process_incoming_message(phone, \"Hello\", agent_id)\n\ncustomer = context.customer\nprint(f\"Phone: {customer.phone}\")\nprint(f\"Name: {customer.name}\")\nprint(f\"Total Messages: {customer.total_messages}\")\nprint(f\"VIP: {customer.is_vip}\")\nprint(f\"Tags: {customer.tags}\")\nprint(f\"Notes: {customer.notes}\")\nprint(f\"Last Contact: {customer.last_contact}\")\nprint(f\"Sentiment History: {customer.sentiment_history}\")"
      },
      {
        "title": "Use Case 1: Order Status Inquiry",
        "body": "# Customer: \"Where is my order?\"\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"Where is my order?\",\n    agent_id=\"agent_001\"\n)\n\n# Agent sees:\nif context.active_orders:\n    order = context.active_orders[0]\n    print(f\"Order ID: {order.order_id}\")\n    print(f\"Status: {order.status}\")\n    print(f\"Tracking: {order.tracking_number}\")\n    print(f\"Est. Delivery: {order.estimated_delivery}\")\n\n# Suggested response\nprint(context.suggested_responses[0])\n# \"Your order #ORD-12345 is shipped. Tracking: TRK-ABC123\""
      },
      {
        "title": "Use Case 2: Angry Customer",
        "body": "# Customer: \"This is TERRIBLE! I want a refund NOW!!!\"\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"This is TERRIBLE! I want a refund NOW!!!\",\n    agent_id=\"agent_001\"\n)\n\n# System detects:\nprint(context.priority.value)   # \"critical\"\nprint(context.sentiment.value)  # \"very_negative\"\n\n# Agent sees warnings:\nfor warning in context.warnings:\n    print(warning)\n# \"🚨 CRITICAL: Requires immediate attention!\"\n# \"😡 Customer is very upset - handle with care\"\n\n# Suggested response\nprint(context.suggested_responses[0])\n# \"I sincerely apologize for the inconvenience. Let me help resolve this.\""
      },
      {
        "title": "Use Case 3: Multiple Customers Priority Queue",
        "body": "# Process messages from multiple customers\ncustomers = [\n    (\"+1111111111\", \"Can I get some info?\"),\n    (\"+2222222222\", \"My payment failed!!!\"),\n    (\"+3333333333\", \"I have a complaint\"),\n    (\"+4444444444\", \"Thanks for the help!\"),\n]\n\ncontexts = []\nfor phone, message in customers:\n    context = manager.process_incoming_message(phone, message, \"agent_001\")\n    contexts.append((phone, context))\n\n# Sort by priority\npriority_order = {\n    MessagePriority.CRITICAL: 0,\n    MessagePriority.HIGH: 1,\n    MessagePriority.NORMAL: 2,\n    MessagePriority.LOW: 3\n}\ncontexts.sort(key=lambda x: priority_order[x[1].priority])\n\n# Agent dashboard shows:\n# 1. 🔴 +2222222222 - CRITICAL - Payment failed\n# 2. 🟠 +3333333333 - HIGH - Complaint\n# 3. 🟡 +1111111111 - NORMAL - Info request\n# 4. 🟢 +4444444444 - LOW - Thank you message"
      },
      {
        "title": "Use Case 4: First-time vs Returning Customer",
        "body": "# System automatically tracks\ncontext = manager.process_incoming_message(\n    phone=\"+9999999999\",  # New number\n    message_content=\"Hello\",\n    agent_id=\"agent_001\"\n)\n\n# Check if first time\nif context.customer.total_messages == 1:\n    print(\"👋 First time customer!\")\n    # Show introduction, onboarding info\nelse:\n    print(f\"📊 Returning customer ({context.customer.total_messages} messages)\")\n    # Show history, previous orders"
      },
      {
        "title": "With WhatsApp Business API",
        "body": "from whatsapp_business_api import WhatsAppClient\nfrom whatsapp_context_manager import ContextManager\n\n# Initialize\nwa_client = WhatsAppClient(api_key=\"your_key\")\nmanager = ContextManager(\"production.db\")\n\n# Handle incoming messages\n@wa_client.on_message\ndef handle_message(phone, message):\n    # Get context\n    context = manager.process_incoming_message(\n        phone=phone,\n        message_content=message,\n        agent_id=\"auto_agent\"\n    )\n    \n    # Display to agent dashboard\n    display_to_agent(context)\n    \n    # If critical, alert supervisor\n    if context.priority == MessagePriority.CRITICAL:\n        notify_supervisor(context)"
      },
      {
        "title": "With Web Dashboard",
        "body": "from flask import Flask, jsonify\nfrom whatsapp_context_manager import ContextManager\n\napp = Flask(__name__)\nmanager = ContextManager()\n\n@app.route('/api/message', methods=['POST'])\ndef process_message():\n    data = request.json\n    \n    # Process message\n    context = manager.process_incoming_message(\n        phone=data['phone'],\n        message_content=data['message'],\n        agent_id=data['agent_id']\n    )\n    \n    # Return context as JSON\n    return jsonify(context.to_dict())"
      },
      {
        "title": "1. Always Process Through System",
        "body": "# Good ✅\ncontext = manager.process_incoming_message(phone, message, agent_id)\n# Agent has full context\n\n# Bad ❌\n# Responding without context\nsend_reply_directly(phone, \"Hello\")  # Agent is blind"
      },
      {
        "title": "2. Mark VIP Customers",
        "body": "# Identify high-value customers early\nif customer_is_high_value(phone):\n    manager.update_customer_info(\n        phone=phone,\n        is_vip=True,\n        tags=[\"high-value\", \"premium\"]\n    )"
      },
      {
        "title": "3. Track Orders",
        "body": "# Add orders to system for automatic context\nwhen_order_placed():\n    manager.add_order(order)\n    \n# Now agents automatically see order status when customer asks"
      },
      {
        "title": "4. Use Suggested Responses",
        "body": "# Get AI suggestions\ncontext = manager.process_incoming_message(phone, message, agent_id)\n\n# Show to agent for quick selection\nfor i, response in enumerate(context.suggested_responses, 1):\n    print(f\"{i}. {response}\")"
      },
      {
        "title": "5. Monitor Priority Queue",
        "body": "# Get all pending messages\npending_contexts = get_all_pending_messages()\n\n# Sort by priority\npending_contexts.sort(key=lambda x: priority_order[x.priority])\n\n# Agents work from top (critical) to bottom (low)"
      },
      {
        "title": "1. Database Management",
        "body": "# Use separate databases for different purposes\ndev_manager = ContextManager(\"development.db\")\nprod_manager = ContextManager(\"production.db\")\ntest_manager = ContextManager(\"test.db\")"
      },
      {
        "title": "2. Batch Processing",
        "body": "# Process multiple messages efficiently\nfor phone, message in message_queue:\n    context = manager.process_incoming_message(phone, message, agent_id)\n    process_context(context)"
      },
      {
        "title": "3. Regular Cleanup",
        "body": "# Archive old conversations (optional)\n# System stores everything by default\n# Implement custom archival if needed"
      },
      {
        "title": "Security Features",
        "body": "Local Storage: All data stored locally in SQLite\nNo External Dependencies: Pure Python, no third-party libraries\nData Integrity: SHA-256 checksums\nSecure Queries: Parameterized SQL, no injection risks\nPrivacy: No data sent to external services"
      },
      {
        "title": "Issue: Database locked",
        "body": "# Use different database per process\nmanager1 = ContextManager(\"agent1.db\")\nmanager2 = ContextManager(\"agent2.db\")"
      },
      {
        "title": "Issue: Old data in tests",
        "body": "# Clean up test databases\nimport os\nif os.path.exists(\"test.db\"):\n    os.remove(\"test.db\")"
      },
      {
        "title": "Issue: No order suggestions",
        "body": "# Make sure orders are added to system\norder = Order(...)\nmanager.add_order(order)"
      },
      {
        "title": "File Structure",
        "body": "whatsapp-context-manager/\n├── whatsapp_context_manager.py  # Main library\n├── examples_whatsapp.py         # 8 usage examples\n├── test_whatsapp.py             # Complete test suite\n├── README_WHATSAPP.md           # Full documentation\n├── install_check_whatsapp.py    # Installation check\n├── requirements_whatsapp.txt    # Dependencies (none!)\n├── LICENSE_WHATSAPP             # MIT License\n└── .gitignore_whatsapp          # Git ignore rules"
      },
      {
        "title": "Requirements",
        "body": "Python 3.8 or higher\nNo external dependencies!"
      },
      {
        "title": "Testing",
        "body": "# Run all tests\npython test_whatsapp.py\n\n# Should show:\n# ✅ Sentiment analysis tests passed\n# ✅ Message categorization tests passed\n# ✅ Priority calculation tests passed\n# ✅ Customer management tests passed\n# ✅ Message storage tests passed\n# ✅ Order management tests passed\n# ✅ VIP customer tests passed\n# ✅ Sentiment tracking tests passed\n# ✅ Response suggestions tests passed\n# ✅ Priority queue tests passed\n# ✅ Conversation flow tests passed\n# ✅ Context export tests passed\n# ✅ ALL TESTS PASSED"
      },
      {
        "title": "Examples",
        "body": "Run the examples to see the system in action:\n\npython examples_whatsapp.py\n\nIncludes:\n\nBasic message processing\nCustomer with active order\nAngry customer scenario\nVIP customer handling\nConversation history\nMultiple customers priority queue\nAgent dashboard view\nContext export to JSON"
      },
      {
        "title": "Getting Help",
        "body": "📖 Read full documentation: README_WHATSAPP.md\n💻 Check examples: examples_whatsapp.py\n🧪 Run tests: test_whatsapp.py\n🐛 Report issues on GitHub\n⭐ Star the repo if helpful!"
      },
      {
        "title": "Next Steps",
        "body": "✅ Install and verify: python install_check_whatsapp.py\n✅ Run tests: python test_whatsapp.py\n✅ Try examples: python examples_whatsapp.py\n✅ Integrate with your WhatsApp system\n✅ Customize for your needs"
      },
      {
        "title": "License",
        "body": "MIT License - see LICENSE_WHATSAPP file"
      },
      {
        "title": "Author",
        "body": "cerbug45\n\nGitHub: @cerbug45\n\nTransform your WhatsApp customer service from reactive to proactive! 🚀"
      }
    ],
    "body": "WhatsApp Intelligent Context Manager - Skill Guide\n\nThis skill provides an AI-powered context management system for WhatsApp customer service agents, enabling instant access to customer history, sentiment analysis, and smart response suggestions.\n\nQuick Installation\n# Download and extract\nunzip whatsapp-context-manager.zip\ncd whatsapp-context-manager\n\n# Verify installation (no dependencies needed!)\npython install_check_whatsapp.py\n\n# Run tests\npython test_whatsapp.py\n\n# Try examples\npython examples_whatsapp.py\n\nWhat Problem Does This Solve?\n\nWithout This System:\n\n❌ Agents have no context when customer messages arrive\n❌ No idea if customer is VIP or first-timer\n❌ Can't see order status without switching systems\n❌ Don't know if message is urgent or can wait\n❌ Guessing what to say instead of smart suggestions\n\nWith This System:\n\n✅ Complete customer context in 2 seconds\n✅ Automatic sentiment analysis (angry/happy/neutral)\n✅ Smart priority (critical/high/normal/low)\n✅ Order status right there\n✅ AI-powered response suggestions\n✅ VIP customer detection\nBasic Usage\n1. Initialize the System\nfrom whatsapp_context_manager import ContextManager\n\n# Create context manager (creates local database)\nmanager = ContextManager(\"production.db\")\n\n2. Process Incoming WhatsApp Message\n# When a WhatsApp message arrives\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"Where is my order?!\",\n    agent_id=\"agent_001\"\n)\n\n3. Display Context to Agent\n# Show agent what they need to know\nprint(f\"Priority: {context.priority.value}\")        # \"critical\"\nprint(f\"Sentiment: {context.sentiment.value}\")      # \"negative\"\nprint(f\"Category: {context.category}\")              # \"order_status\"\nprint(f\"VIP Customer: {context.customer.is_vip}\")   # True/False\n\n# Key insights\nfor insight in context.key_insights:\n    print(f\"💡 {insight}\")\n\n# Warnings\nfor warning in context.warnings:\n    print(f\"⚠️ {warning}\")\n\n# Suggested responses\nfor response in context.suggested_responses:\n    print(f\"💬 {response}\")\n\n4. Send Reply\n# Agent sends reply\nmanager.send_message(\n    phone=\"+1234567890\",\n    message_content=\"Your order #12345 is on the way!\",\n    agent_id=\"agent_001\"\n)\n\nWhat Agent Sees - Dashboard Example\n┌──────────────────────────────────────────────────────┐\n│                  AGENT DASHBOARD                     │\n├──────────────────────────────────────────────────────┤\n│ Customer: +1234567890                                │\n│ Name: John Doe                                       │\n│ VIP: YES                                             │\n├──────────────────────────────────────────────────────┤\n│ Priority: CRITICAL                                   │\n│ Sentiment: NEGATIVE                                  │\n│ Category: ORDER_STATUS                               │\n├──────────────────────────────────────────────────────┤\n│ KEY INSIGHTS:                                        │\n│   • 🌟 VIP Customer - Prioritize response            │\n│   • 📦 Active Order: #ORD-12345 - shipped            │\n│   • 🚚 Tracking: TRK-ABC123                          │\n│   • ⚡ Customer expects fast replies (~2min)         │\n├──────────────────────────────────────────────────────┤\n│ WARNINGS:                                            │\n│   • 🚨 CRITICAL: Requires immediate attention!       │\n│   • 😡 Customer is very upset - handle with care     │\n├──────────────────────────────────────────────────────┤\n│ SUGGESTED RESPONSES:                                 │\n│   1. Let me check your order status right away.     │\n│   2. Your order #ORD-12345 is shipped.               │\n└──────────────────────────────────────────────────────┘\n\nCore Features\n1. Automatic Sentiment Analysis\n\nDetects customer mood from message:\n\n# System automatically analyzes sentiment\ncontext = manager.process_incoming_message(phone, \"This is TERRIBLE!\", agent_id)\nprint(context.sentiment.value)  # \"very_negative\"\n\ncontext = manager.process_incoming_message(phone, \"Thanks!\", agent_id)\nprint(context.sentiment.value)  # \"positive\"\n\n\nSentiment Levels:\n\n😡 very_negative - Angry, furious, scam\n😟 negative - Disappointed, problem\n😐 neutral - Questions, info requests\n😊 positive - Thanks, happy\n🤩 very_positive - Excellent, love it\n2. Message Categorization\n\nAutomatically categorizes messages:\n\n# System automatically categorizes\ncontext = manager.process_incoming_message(phone, \"Where is my package?\", agent_id)\nprint(context.category)  # MessageCategory.ORDER_STATUS\n\ncontext = manager.process_incoming_message(phone, \"Refund please!\", agent_id)\nprint(context.category)  # MessageCategory.PAYMENT\n\n\nCategories:\n\n📦 ORDER_STATUS - Delivery, tracking, shipment\n💳 PAYMENT - Refund, billing, transaction\n🔴 COMPLAINT - Problem, issue, broken\n🛍️ PRODUCT_INQUIRY - Price, stock, features\n🆘 SUPPORT - Help, how-to, questions\n💰 SALES - Buy, purchase, interested\n⭐ FEEDBACK - Review, opinion\n❓ OTHER - Uncategorized\n3. Priority Calculation\n\nSmart priority based on multiple factors:\n\n# System calculates priority\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"My payment failed!!!\",\n    agent_id=\"agent_001\"\n)\nprint(context.priority.value)  # \"critical\"\n\n\nPriority Levels:\n\n🔴 CRITICAL - Angry customer, payment issue, VIP unhappy\n🟠 HIGH - Complaints, negative sentiment\n🟡 NORMAL - General questions\n🟢 LOW - Info requests, positive feedback\n4. Response Suggestions\n\nAI suggests appropriate responses:\n\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"When will my order arrive?\",\n    agent_id=\"agent_001\"\n)\n\n# Get suggestions\nfor response in context.suggested_responses:\n    print(response)\n# Output:\n# \"Let me check your order status right away.\"\n# \"Your order #12345 is currently shipped.\"\n# \"Expected delivery is tomorrow.\"\n\nAdvanced Features\nOrder Integration\n\nAdd and track customer orders:\n\nfrom whatsapp_context_manager import Order\nfrom datetime import datetime, timedelta\n\n# Add order to system\norder = Order(\n    order_id=\"ORD-12345\",\n    customer_id=context.customer.customer_id,\n    status=\"shipped\",\n    amount=99.99,\n    items=[\n        {\"name\": \"Wireless Headphones\", \"quantity\": 1, \"price\": 99.99}\n    ],\n    created_at=datetime.now().isoformat(),\n    updated_at=datetime.now().isoformat(),\n    tracking_number=\"TRK-ABC123\",\n    estimated_delivery=(datetime.now() + timedelta(days=2)).strftime(\"%Y-%m-%d\")\n)\n\nmanager.add_order(order)\n\n# Now when customer asks about order, agent sees all details\ncontext = manager.process_incoming_message(phone, \"Order status?\", agent_id)\nprint(context.active_orders[0].tracking_number)  # \"TRK-ABC123\"\n\nVIP Customer Management\n\nMark and manage VIP customers:\n\n# Update customer to VIP\nmanager.update_customer_info(\n    phone=\"+1234567890\",\n    name=\"John Doe\",\n    email=\"john@example.com\",\n    is_vip=True,\n    tags=[\"premium\", \"loyal\", \"high-value\"],\n    notes=\"Always responds best to quick, direct answers\"\n)\n\n# Future messages automatically show VIP status\ncontext = manager.process_incoming_message(phone, \"Hello\", agent_id)\nprint(context.customer.is_vip)  # True\nprint(context.customer.tags)    # [\"premium\", \"loyal\", \"high-value\"]\n\nConversation History\n\nAccess complete conversation history:\n\n# Get context (includes recent messages)\ncontext = manager.process_incoming_message(phone, \"Need help\", agent_id)\n\n# View recent messages\nfor msg in context.recent_messages:\n    direction = \"Customer\" if msg.direction == \"inbound\" else \"Agent\"\n    print(f\"{direction}: {msg.content}\")\n\nCustomer Profile\n\nAccess complete customer profile:\n\ncontext = manager.process_incoming_message(phone, \"Hello\", agent_id)\n\ncustomer = context.customer\nprint(f\"Phone: {customer.phone}\")\nprint(f\"Name: {customer.name}\")\nprint(f\"Total Messages: {customer.total_messages}\")\nprint(f\"VIP: {customer.is_vip}\")\nprint(f\"Tags: {customer.tags}\")\nprint(f\"Notes: {customer.notes}\")\nprint(f\"Last Contact: {customer.last_contact}\")\nprint(f\"Sentiment History: {customer.sentiment_history}\")\n\nCommon Use Cases\nUse Case 1: Order Status Inquiry\n# Customer: \"Where is my order?\"\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"Where is my order?\",\n    agent_id=\"agent_001\"\n)\n\n# Agent sees:\nif context.active_orders:\n    order = context.active_orders[0]\n    print(f\"Order ID: {order.order_id}\")\n    print(f\"Status: {order.status}\")\n    print(f\"Tracking: {order.tracking_number}\")\n    print(f\"Est. Delivery: {order.estimated_delivery}\")\n\n# Suggested response\nprint(context.suggested_responses[0])\n# \"Your order #ORD-12345 is shipped. Tracking: TRK-ABC123\"\n\nUse Case 2: Angry Customer\n# Customer: \"This is TERRIBLE! I want a refund NOW!!!\"\ncontext = manager.process_incoming_message(\n    phone=\"+1234567890\",\n    message_content=\"This is TERRIBLE! I want a refund NOW!!!\",\n    agent_id=\"agent_001\"\n)\n\n# System detects:\nprint(context.priority.value)   # \"critical\"\nprint(context.sentiment.value)  # \"very_negative\"\n\n# Agent sees warnings:\nfor warning in context.warnings:\n    print(warning)\n# \"🚨 CRITICAL: Requires immediate attention!\"\n# \"😡 Customer is very upset - handle with care\"\n\n# Suggested response\nprint(context.suggested_responses[0])\n# \"I sincerely apologize for the inconvenience. Let me help resolve this.\"\n\nUse Case 3: Multiple Customers Priority Queue\n# Process messages from multiple customers\ncustomers = [\n    (\"+1111111111\", \"Can I get some info?\"),\n    (\"+2222222222\", \"My payment failed!!!\"),\n    (\"+3333333333\", \"I have a complaint\"),\n    (\"+4444444444\", \"Thanks for the help!\"),\n]\n\ncontexts = []\nfor phone, message in customers:\n    context = manager.process_incoming_message(phone, message, \"agent_001\")\n    contexts.append((phone, context))\n\n# Sort by priority\npriority_order = {\n    MessagePriority.CRITICAL: 0,\n    MessagePriority.HIGH: 1,\n    MessagePriority.NORMAL: 2,\n    MessagePriority.LOW: 3\n}\ncontexts.sort(key=lambda x: priority_order[x[1].priority])\n\n# Agent dashboard shows:\n# 1. 🔴 +2222222222 - CRITICAL - Payment failed\n# 2. 🟠 +3333333333 - HIGH - Complaint\n# 3. 🟡 +1111111111 - NORMAL - Info request\n# 4. 🟢 +4444444444 - LOW - Thank you message\n\nUse Case 4: First-time vs Returning Customer\n# System automatically tracks\ncontext = manager.process_incoming_message(\n    phone=\"+9999999999\",  # New number\n    message_content=\"Hello\",\n    agent_id=\"agent_001\"\n)\n\n# Check if first time\nif context.customer.total_messages == 1:\n    print(\"👋 First time customer!\")\n    # Show introduction, onboarding info\nelse:\n    print(f\"📊 Returning customer ({context.customer.total_messages} messages)\")\n    # Show history, previous orders\n\nIntegration Examples\nWith WhatsApp Business API\nfrom whatsapp_business_api import WhatsAppClient\nfrom whatsapp_context_manager import ContextManager\n\n# Initialize\nwa_client = WhatsAppClient(api_key=\"your_key\")\nmanager = ContextManager(\"production.db\")\n\n# Handle incoming messages\n@wa_client.on_message\ndef handle_message(phone, message):\n    # Get context\n    context = manager.process_incoming_message(\n        phone=phone,\n        message_content=message,\n        agent_id=\"auto_agent\"\n    )\n    \n    # Display to agent dashboard\n    display_to_agent(context)\n    \n    # If critical, alert supervisor\n    if context.priority == MessagePriority.CRITICAL:\n        notify_supervisor(context)\n\nWith Web Dashboard\nfrom flask import Flask, jsonify\nfrom whatsapp_context_manager import ContextManager\n\napp = Flask(__name__)\nmanager = ContextManager()\n\n@app.route('/api/message', methods=['POST'])\ndef process_message():\n    data = request.json\n    \n    # Process message\n    context = manager.process_incoming_message(\n        phone=data['phone'],\n        message_content=data['message'],\n        agent_id=data['agent_id']\n    )\n    \n    # Return context as JSON\n    return jsonify(context.to_dict())\n\nBest Practices\n1. Always Process Through System\n# Good ✅\ncontext = manager.process_incoming_message(phone, message, agent_id)\n# Agent has full context\n\n# Bad ❌\n# Responding without context\nsend_reply_directly(phone, \"Hello\")  # Agent is blind\n\n2. Mark VIP Customers\n# Identify high-value customers early\nif customer_is_high_value(phone):\n    manager.update_customer_info(\n        phone=phone,\n        is_vip=True,\n        tags=[\"high-value\", \"premium\"]\n    )\n\n3. Track Orders\n# Add orders to system for automatic context\nwhen_order_placed():\n    manager.add_order(order)\n    \n# Now agents automatically see order status when customer asks\n\n4. Use Suggested Responses\n# Get AI suggestions\ncontext = manager.process_incoming_message(phone, message, agent_id)\n\n# Show to agent for quick selection\nfor i, response in enumerate(context.suggested_responses, 1):\n    print(f\"{i}. {response}\")\n\n5. Monitor Priority Queue\n# Get all pending messages\npending_contexts = get_all_pending_messages()\n\n# Sort by priority\npending_contexts.sort(key=lambda x: priority_order[x.priority])\n\n# Agents work from top (critical) to bottom (low)\n\nPerformance Tips\n1. Database Management\n# Use separate databases for different purposes\ndev_manager = ContextManager(\"development.db\")\nprod_manager = ContextManager(\"production.db\")\ntest_manager = ContextManager(\"test.db\")\n\n2. Batch Processing\n# Process multiple messages efficiently\nfor phone, message in message_queue:\n    context = manager.process_incoming_message(phone, message, agent_id)\n    process_context(context)\n\n3. Regular Cleanup\n# Archive old conversations (optional)\n# System stores everything by default\n# Implement custom archival if needed\n\nSecurity Features\nLocal Storage: All data stored locally in SQLite\nNo External Dependencies: Pure Python, no third-party libraries\nData Integrity: SHA-256 checksums\nSecure Queries: Parameterized SQL, no injection risks\nPrivacy: No data sent to external services\nTroubleshooting\nIssue: Database locked\n# Use different database per process\nmanager1 = ContextManager(\"agent1.db\")\nmanager2 = ContextManager(\"agent2.db\")\n\nIssue: Old data in tests\n# Clean up test databases\nimport os\nif os.path.exists(\"test.db\"):\n    os.remove(\"test.db\")\n\nIssue: No order suggestions\n# Make sure orders are added to system\norder = Order(...)\nmanager.add_order(order)\n\nFile Structure\nwhatsapp-context-manager/\n├── whatsapp_context_manager.py  # Main library\n├── examples_whatsapp.py         # 8 usage examples\n├── test_whatsapp.py             # Complete test suite\n├── README_WHATSAPP.md           # Full documentation\n├── install_check_whatsapp.py    # Installation check\n├── requirements_whatsapp.txt    # Dependencies (none!)\n├── LICENSE_WHATSAPP             # MIT License\n└── .gitignore_whatsapp          # Git ignore rules\n\nRequirements\nPython 3.8 or higher\nNo external dependencies!\nTesting\n# Run all tests\npython test_whatsapp.py\n\n# Should show:\n# ✅ Sentiment analysis tests passed\n# ✅ Message categorization tests passed\n# ✅ Priority calculation tests passed\n# ✅ Customer management tests passed\n# ✅ Message storage tests passed\n# ✅ Order management tests passed\n# ✅ VIP customer tests passed\n# ✅ Sentiment tracking tests passed\n# ✅ Response suggestions tests passed\n# ✅ Priority queue tests passed\n# ✅ Conversation flow tests passed\n# ✅ Context export tests passed\n# ✅ ALL TESTS PASSED\n\nExamples\n\nRun the examples to see the system in action:\n\npython examples_whatsapp.py\n\n\nIncludes:\n\nBasic message processing\nCustomer with active order\nAngry customer scenario\nVIP customer handling\nConversation history\nMultiple customers priority queue\nAgent dashboard view\nContext export to JSON\nGetting Help\n📖 Read full documentation: README_WHATSAPP.md\n💻 Check examples: examples_whatsapp.py\n🧪 Run tests: test_whatsapp.py\n🐛 Report issues on GitHub\n⭐ Star the repo if helpful!\nNext Steps\n✅ Install and verify: python install_check_whatsapp.py\n✅ Run tests: python test_whatsapp.py\n✅ Try examples: python examples_whatsapp.py\n✅ Integrate with your WhatsApp system\n✅ Customize for your needs\nLicense\n\nMIT License - see LICENSE_WHATSAPP file\n\nAuthor\n\ncerbug45\n\nGitHub: @cerbug45\n\nTransform your WhatsApp customer service from reactive to proactive! 🚀"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/cerbug45/whatsapp-context-manager",
    "publisherUrl": "https://clawhub.ai/cerbug45/whatsapp-context-manager",
    "owner": "cerbug45",
    "version": "0.1.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/whatsapp-context-manager",
    "downloadUrl": "https://openagent3.xyz/downloads/whatsapp-context-manager",
    "agentUrl": "https://openagent3.xyz/skills/whatsapp-context-manager/agent",
    "manifestUrl": "https://openagent3.xyz/skills/whatsapp-context-manager/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/whatsapp-context-manager/agent.md"
  }
}