diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000..b310a38 --- /dev/null +++ b/SKILL.md @@ -0,0 +1,16 @@ +# Microsoft To Do + +When the user asks to add a reminder, todo, task, or Microsoft To Do item, call the n8n webhook. + +The webhook URL is provided by the environment variable `N8N_TODO_WEBHOOK_URL`. + +Input JSON format: + +```json +{ + "title": "续费 OVH", + "due": "2026-05-21T15:00:00", + "reminder": "2026-05-21T15:00:00" +} +``` +Use local Asia/Shanghai time unless the user specifies another timezone. \ No newline at end of file diff --git a/add_todo.py b/add_todo.py new file mode 100644 index 0000000..761cebc --- /dev/null +++ b/add_todo.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +import json +import os +import sys +import urllib.request + +def main(): + if len(sys.argv) < 2: + print(json.dumps({"ok": False, "error": "missing title"}, ensure_ascii=False)) + return + + url = os.environ.get("N8N_TODO_WEBHOOK_URL") + if not url: + print(json.dumps({"ok": False, "error": "N8N_TODO_WEBHOOK_URL not set"}, ensure_ascii=False)) + return + + title = sys.argv[1] + due = sys.argv[2] if len(sys.argv) > 2 else "" + reminder = sys.argv[3] if len(sys.argv) > 3 else due + + payload = { + "title": title, + "due": due, + "reminder": reminder, + } + + req = urllib.request.Request( + url, + data=json.dumps(payload).encode("utf-8"), + headers={"Content-Type": "application/json"}, + method="POST", + ) + + with urllib.request.urlopen(req, timeout=20) as resp: + print(resp.read().decode("utf-8", "ignore")) + +if __name__ == "__main__": + main() \ No newline at end of file