92 lines
3.2 KiB
Python
92 lines
3.2 KiB
Python
import os
|
|
import requests
|
|
import json
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv(dotenv_path="/home/node/clawd/.env")
|
|
|
|
NOTION_TOKEN = os.getenv("NOTION_API_KEY")
|
|
HEADERS = {
|
|
"Authorization": f"Bearer {NOTION_TOKEN}",
|
|
"Content-Type": "application/json",
|
|
"Notion-Version": "2022-06-28"
|
|
}
|
|
|
|
PROJECT_ID = "2ea88f42-8544-8074-9ad8-c24d283bc1c9"
|
|
|
|
def find_tasks_db():
|
|
url = "https://api.notion.com/v1/search"
|
|
payload = {"query": "Tasks", "filter": {"value": "database", "property": "object"}}
|
|
resp = requests.post(url, headers=HEADERS, json=payload)
|
|
if resp.status_code == 200:
|
|
results = resp.json().get("results", [])
|
|
if results:
|
|
return results[0]['id']
|
|
return None
|
|
|
|
def create_log_entry():
|
|
db_id = find_tasks_db()
|
|
if not db_id:
|
|
print("❌ Tasks DB not found.")
|
|
return
|
|
|
|
# Content for 16.02.
|
|
content = """# Tages-Log: 16.02.2026 (Nachtrag)
|
|
|
|
## Zusammenfassung
|
|
Durchbruch bei der technischen Integration zwischen SuperOffice CRM und Company Explorer. Der bidirektionale Datenaustausch steht.
|
|
|
|
## Erreichte Meilensteine
|
|
|
|
### 1. SuperOffice Integration (Deep Dive)
|
|
- **Status:** ✅ **POC Erfolgreich.**
|
|
- **Token-Management:** Automatische Refresh-Logik implementiert (kein manuelles Login mehr nötig).
|
|
- **Write-Back:** Erfolgreiches Update von Firmen-Daten (Adresse, VAT, URL) in SuperOffice.
|
|
- **Hürden genommen:**
|
|
- **Pflichtfelder:** Fehler mit `Number2` (unbekanntes Pflichtfeld) identifiziert und umgangen.
|
|
- **Listen-Objekte:** Korrekte Syntax für das Update von Dropdowns (Branche) gefunden (`Select` vs `Id`).
|
|
|
|
### 2. Company Explorer Connector
|
|
- **Status:** ✅ **Client fertig.**
|
|
- **Workflow:** Skript `company_explorer_connector.py` steuert jetzt den Upload von Firmen und das Abholen der Ergebnisse.
|
|
|
|
### 3. Regeln der Zusammenarbeit
|
|
- **Core Directive V2.0:** Fokus auf "Ehrlicher Partner" und präzise technische Umsetzung ohne Floskeln definiert.
|
|
|
|
## Fazit
|
|
Die "Rohre" zwischen den Systemen sind verlegt. Daten können fließen.
|
|
"""
|
|
|
|
blocks = []
|
|
for line in content.split('\n'):
|
|
blocks.append({
|
|
"object": "block",
|
|
"type": "paragraph",
|
|
"paragraph": {"rich_text": [{"type": "text", "text": {"content": line}}]}
|
|
})
|
|
|
|
url = "https://api.notion.com/v1/pages"
|
|
payload = {
|
|
"parent": {"database_id": db_id},
|
|
"properties": {
|
|
"Name": {"title": [{"text": {"content": "Tages-Log 16.02.2026 (Nachtrag)"}}]},
|
|
"Status": {"status": {"name": "Done"}},
|
|
"Project": {"relation": [{"id": PROJECT_ID}]}
|
|
},
|
|
"children": blocks[:90]
|
|
}
|
|
|
|
resp = requests.post(url, headers=HEADERS, json=payload)
|
|
if resp.status_code == 200:
|
|
print("✅ Nachtrag 16.02. erstellt.")
|
|
else:
|
|
# Fallback Name/Task check
|
|
if "Name is not a property" in resp.text:
|
|
payload["properties"].pop("Name")
|
|
payload["properties"]["Task"] = {"title": [{"text": {"content": "Tages-Log 16.02.2026 (Nachtrag)"}}]}
|
|
requests.post(url, headers=HEADERS, json=payload)
|
|
print("✅ Nachtrag 16.02. erstellt (Fallback).")
|
|
|
|
if __name__ == "__main__":
|
|
create_log_entry()
|