Scheduled Change Notifications

Checks for changes on a schedule and sends a notification when new data appears. The example tracks a GitHub repository's star count and sends updates to Telegram.

Hermes Intermediate Copied: 0
1 resource

Requirements

  • Cron with built-in --script support.
  • A checker script located in ~/.hermes/scripts/.
  • Any configured messaging delivery target.

How to use

  1. Create a checker script and place it in ~/.hermes/scripts/.
   # ~/.hermes/scripts/watch-stars.py
   import json, os, urllib.request

   REPO = "NousResearch/hermes-agent"
   STATE = os.path.expanduser("~/.hermes/scripts/.stars-state.json")

   def get_stars():
       req = urllib.request.Request(
           f"https://api.github.com/repos/{REPO}",
           headers={"User-Agent": "hermes-watcher"},
       )
       return json.loads(urllib.request.urlopen(req).read())["stargazers_count"]

   prev = json.load(open(STATE))["count"] if os.path.exists(STATE) else None
   curr = get_stars()
   json.dump({"count": curr}, open(STATE, "w"))

   if prev is None:
       print("INITIAL", curr)
   elif curr == prev:
       print("NO_CHANGE")
   else:
       print(f"CHANGE {prev} -> {curr}")

  1. Create a job that checks the star count every 15 minutes and sends a change notification to Telegram.
   hermes cron create "*/15 * * * *" \
     "If the script output starts with CHANGE, summarize in one line what
      changed and deliver. If it starts with NO_CHANGE or INITIAL, respond
      with only [SILENT]." \
     --script ~/.hermes/scripts/watch-stars.py \
     --name "Star watcher" \
     --deliver telegram

In this example, [SILENT] suppresses the message when nothing changes, but does not skip the model call. It is not a zero-token mode. See the Hermes documentation.

Source: aliaihub/awesome-hermes-usecases and its contributors. License: CC-BY-4.0. Source license notice.

Translation and editorial adaptation by ClawCases.

>Resources

>Related Use Cases

>More at this level: Intermediate