Last active
February 6, 2026 01:21
-
-
Save cmer/41c0f8768b790eb12d24c63a40ccc718 to your computer and use it in GitHub Desktop.
Wake OpenClaw whenever needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # frozen_string_literal: true | |
| # check-emails.rb - Forward VIP emails to OpenClaw for processing | |
| # | |
| # Cron: */5 * * * * /path/to/check-emails.rb >> /tmp/check-emails.log 2>&1 | |
| require 'json' | |
| VIP_SENDERS = ['[email protected]', '[email protected]'] | |
| SESSION_ID = "hook:email" | |
| def fetch_new_emails | |
| # TODO: Replace with your actual mail source (IMAP, Gmail API, etc.) | |
| # Should return an array of hashes: [{ from:, subject:, body:, id: }, ...] | |
| [] | |
| end | |
| # -- 1. Check for new emails -- | |
| emails = fetch_new_emails | |
| # -- 2. Filter to VIP senders only -- | |
| vip_emails = emails.select { |e| VIP_SENDERS.include?(e[:from]) } | |
| exit 0 if vip_emails.empty? | |
| # -- 3. Send to OpenClaw -- | |
| message = <<~MSG | |
| #{vip_emails.length} new VIP email(s). Read and draft replies. | |
| ```json | |
| #{JSON.pretty_generate(vip_emails)} | |
| ``` | |
| MSG | |
| if system("openclaw", "agent", "--session-id", SESSION_ID, "--message", message) | |
| puts "✓ Forwarded #{vip_emails.length} emails" | |
| else | |
| puts "✗ Failed: exit code #{$?.exitstatus}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment