#!/bin/bash
# Siri Shortcut Webhook for Trello Task Management
# Call this from iOS Siri Shortcuts

# Get the command from query string
COMMAND="${QUERY_STRING:-}"
COMMAND=$(echo "$COMMAND" | sed 's/command=//' | urldecode 2>/dev/null || echo "$COMMAND")

# If no command, check for POST data
if [ -z "$COMMAND" ]; then
    COMMAND=$(cat)
fi

# Output headers
echo "Content-Type: application/json"
echo ""

# Process the command
if [ -n "$COMMAND" ]; then
    # Run the Python script
    RESULT=$(echo "$COMMAND" | python3 /home/ubuntu/.openclaw/workspace/shared/projects/siri-shortcut/task_manager.py)
    echo "$RESULT"
else
    echo '{"response": "Say a command like: Move Pay Marie to Quick Wins", "status": "ready"}'
fi
