commit f13dcbf337c4d8686d713bb96b4879b1a0b5ebee Author: templarz Date: Wed May 20 16:20:23 2026 +0000 add microsoft todo hermes plugin diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..58f5a8a --- /dev/null +++ b/__init__.py @@ -0,0 +1,75 @@ +import json +import os +import urllib.request + + +def register(ctx): + def add_microsoft_todo(title: str, due: str = "", reminder: str = "") -> str: + url = os.environ.get("N8N_TODO_WEBHOOK_URL") + if not url: + return json.dumps({ + "ok": False, + "error": "N8N_TODO_WEBHOOK_URL is not set" + }, ensure_ascii=False) + + payload = { + "title": title, + "due": due, + "reminder": reminder or due, + } + + req = urllib.request.Request( + url, + data=json.dumps(payload).encode("utf-8"), + headers={"Content-Type": "application/json"}, + method="POST", + ) + + try: + with urllib.request.urlopen(req, timeout=20) as resp: + body = resp.read().decode("utf-8", "ignore") + + return json.dumps({ + "ok": True, + "message": "已添加到 Microsoft To Do", + "n8n_response": body, + }, ensure_ascii=False) + + except Exception as e: + return json.dumps({ + "ok": False, + "error": str(e), + }, ensure_ascii=False) + + ctx.register_tool( + name="add_microsoft_todo", + description=( + "Add a task/reminder to Microsoft To Do via n8n. " + "Use this when the user asks to add a reminder, todo, or task. " + "The due and reminder fields should use local ISO datetime format, " + "for example 2026-05-21T15:00:00." + ), + parameters={ + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Task title, for example 续费 OVH" + }, + "due": { + "type": "string", + "description": "Due datetime in local ISO format, for example 2026-05-21T15:00:00" + }, + "reminder": { + "type": "string", + "description": "Reminder datetime in local ISO format, for example 2026-05-21T15:00:00" + } + }, + "required": ["title"] + }, + handler=lambda args, **kwargs: add_microsoft_todo( + title=args.get("title", ""), + due=args.get("due", ""), + reminder=args.get("reminder", ""), + ), + ) \ No newline at end of file diff --git a/plugin.yaml b/plugin.yaml new file mode 100644 index 0000000..d66f09e --- /dev/null +++ b/plugin.yaml @@ -0,0 +1,4 @@ +name: microsoft_todo +version: 1.0.0 +description: Add reminders to Microsoft To Do through an n8n webhook. +author: templarz