add microsoft todo hermes plugin

This commit is contained in:
2026-05-20 16:20:23 +00:00
commit f13dcbf337
2 changed files with 79 additions and 0 deletions

75
__init__.py Normal file
View File

@@ -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", ""),
),
)