69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Check workflow status and details
|
|
"""
|
|
|
|
import json
|
|
import requests
|
|
|
|
# Read API key
|
|
api_key_file = '/home/bam/.n8n_api_key'
|
|
with open(api_key_file, 'r') as f:
|
|
api_key = f.read().strip()
|
|
|
|
# API endpoint
|
|
url = 'https://n8n.oky.sh/api/v1/workflows'
|
|
|
|
# Headers
|
|
headers = {
|
|
'X-N8N-API-KEY': api_key
|
|
}
|
|
|
|
# Get all workflows
|
|
print("Fetching all workflows...")
|
|
response = requests.get(url, headers=headers)
|
|
|
|
if response.status_code == 200:
|
|
workflows = response.json()
|
|
print(f"\nFound {len(workflows)} workflows:")
|
|
|
|
our_workflow = None
|
|
for wf in workflows:
|
|
print(f"\n ID: {wf['id']}")
|
|
print(f" Name: {wf['name']}")
|
|
print(f" Active: {wf['active']}")
|
|
print(f" Nodes: {len(wf.get('nodes', []))}")
|
|
|
|
# Check for our workflow
|
|
if wf.get('name') == 'Todo-Based MVP Builder':
|
|
our_workflow = wf
|
|
print(f"\n🎯 Found our workflow!")
|
|
|
|
if our_workflow:
|
|
print(f"\n{'='*60}")
|
|
print("WORKFLOW DETAILS:")
|
|
print(f"{'='*60}")
|
|
print(f"ID: {our_workflow['id']}")
|
|
print(f"Name: {our_workflow['name']}")
|
|
print(f"Active: {our_workflow['active']}")
|
|
print(f"Nodes: {len(our_workflow.get('nodes', []))}")
|
|
print(f"Webhook URL: https://n8n.oky.sh/webhook/todo-mvp-builder")
|
|
|
|
if our_workflow.get('active'):
|
|
print(f"\n✅ Workflow is ACTIVE!")
|
|
else:
|
|
print(f"\n❌ Workflow is INACTIVE - activating now...")
|
|
wf_id = our_workflow['id']
|
|
activate_response = requests.post(
|
|
f"{url}/{wf_id}/activate",
|
|
headers=headers
|
|
)
|
|
if activate_response.status_code == 200:
|
|
print(f"✅ Activated successfully!")
|
|
else:
|
|
print(f"❌ Activation failed: {activate_response.status_code}")
|
|
print(activate_response.text)
|
|
else:
|
|
print(f"Failed to fetch workflows: {response.status_code}")
|
|
print(response.text)
|