omp packages

@lwlee2608/pi-notify0.5.0

Phone notifications when Pi finishes, fails, or needs you, via Telegram or any shell command (ntfy, Slack, Discord, Pushover). Optional: answer Pi's questions from Telegram with one tap, with pi-ask-user.

GitHub Actions Published 3 days ago MIT ~11.4K downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

Pi Notify

Get a phone notification when Pi finishes, fails, or needs you. Optionally, answer Pi's questions from your phone.

  • Any service: Telegram with guided setup, or ntfy, Slack, Discord, Pushover, Gotify, Bark and others through a shell command.
  • Useful messages: the agent's one-line summary of what it did, or the error text.
  • You choose when: after the next reply, after every reply, when Pi waits for you in a dialog, or when something happens ("notify me when the tests pass").
  • Answer from your phone (optional, needs pi-ask-user): tap an option in Telegram to answer Pi's question in the terminal. See Answer from your phone.
  • Safe defaults: off until you turn it on, TUI only, masked bot tokens, config saved with mode 0600, no runtime dependencies.

The /notify menu on the Notify tab, choosing to get a notification after the next reply and typing a condition

The /notify Setup tab with a Telegram destination and option checkboxes

Install

pi install npm:@lwlee2608/pi-notify
pi install npm:@lwlee2608/pi-ask-user   # optional: answer questions from your phone

Requires Node.js 22.19+ and Pi 1.0.0. Run /reload after installing. Without pi-ask-user, everything else works.

Set up Telegram

  1. Run /notify setup, choose + Add destination, then Telegram.
  2. In Telegram, message @BotFather, send /newbot, and paste the token it gives you.
  3. Open your new bot in Telegram and send it any message, like "hi".
  4. Back in Pi, choose Find my chat and pick your chat.
  5. Choose Save and close and send the test.

Bot tokens are masked as you type and never shown again. To use a shell command instead, see Shell command connector.

Use

/notify opens a menu with two tabs. Notify choices apply at once, for this session only. Setup changes apply to all sessions after Save and close, and Setup does not open while Pi is working.

Command or prompt Result
/notify Open the menu.
/notify once Notify when the next run ends (done or error), then turn off.
/notify on Notify after every run in this session.
/notify off Turn notifications off.
/notify test Send a test now.
/notify setup Add or edit destinations. Not available during a run.
"Notify me when you finish" The agent arms a one-shot notification.
"Notify me when the tests pass" The agent notifies when the tests pass, or at the end of the run if they never pass.
  • Condition: the agent decides when the condition happens and sends a notification at once. Setting one while notifications are off turns on After the next reply.
  • Notify on mid-task questions (Setup tab): also notify when Pi waits for you in a dialog. This does not use up a one-shot. Commands such as /sessions opened during a run can also trigger it.
  • Add a task summary (Setup tab, on by default): the agent ends its final reply with a Summary: line, and the message shows that line instead of done or error.
  • A reply that ends with a question to you counts as finished.
  • No notification when you abort with Esc (a one-shot stays armed), in print, JSON or RPC mode, or when the config is invalid.
  • New, resumed and forked sessions start with notifications off.

Answer from your phone

This feature is optional. Install pi-ask-user 0.5.0 or later, and turn on Notify on mid-task questions. When Pi asks one single-choice question, the Telegram message gets one button for each option:

🔔 fix-login · ~/src/app · waiting for input

Which storage should we use?
 [ SQLite ]
 [ PostgreSQL ]

A tap answers in Pi, and the message changes to ✅ PostgreSQL. If you answer in the terminal first, it changes to Closed in Pi. Questions with several parts or checkboxes, and shell command destinations, get the plain alert. Use a bot only for Pi: Pi confirms the bot's updates, and taps do not reach Pi if another app reads them, for example through a webhook.

Scenarios

/notify once, "fix the login bug"   run ends ──▶ ✅ my-session · ~/src/app · Fixed login redirect; tests pass.
/notify on, run fails               run ends ──▶ ❌ … · 429 rate limit exceeded
"fix the tests, notify me when they pass"
                                    tests pass ─▶ 🔔 … · tests pass   (the end of the run sends nothing)

Privacy

A message contains the session name, the working directory, and one label of at most 120 characters, as in Scenarios. The label is done, error, a reason, the agent's summary line, or the provider's error text. Turn off Add a task summary to send only done or error.

With Notify on mid-task questions on, a pi-ask-user question also sends its text and option labels to Telegram. In a group or channel, any member can tap a button and answer for you.

No other prompt, code or dialog content is sent.

Manual config

Setup writes ~/.pi/agent/pi-notify/config.json (under PI_CODING_AGENT_DIR when set). You can also edit it by hand:

{
  "onPrompt": true,
  "nerdFont": false,
  "summaries": true,
  "connectors": [
    { "type": "telegram", "botToken": "$TELEGRAM_BOT_TOKEN", "chatId": "$TELEGRAM_CHAT_ID" }
  ]
}
  • A value that is only $VAR comes from Pi's environment. Literal strings also work.
  • onPrompt is Notify on mid-task questions (default false). summaries is Add a task summary (default true). nerdFont shows the Nerd Font bell in the status bar instead of 🔔.
  • Every connector gets each notification. Edits apply at the next send, without /reload.
  • Keep tokens private. Setup saves the file with mode 0600.

Shell command connector

Send to ntfy, Slack, or any other service with a local command. The message is in PI_NOTIFY_TEXT:

{
  "connectors": [
    { "type": "command", "run": "curl -fsS --data-binary \"$PI_NOTIFY_TEXT\" https://ntfy.sh/YOUR_PRIVATE_TOPIC" }
  ]
}
Service run
ntfy curl -fsS --data-binary "$PI_NOTIFY_TEXT" https://ntfy.sh/YOUR_PRIVATE_TOPIC
Gotify curl -fsS --form-string "message=$PI_NOTIFY_TEXT" "https://GOTIFY_HOST/message?token=$GOTIFY_TOKEN"
Pushover curl -fsS --form-string "token=$PUSHOVER_TOKEN" --form-string "user=$PUSHOVER_USER" --form-string "message=$PI_NOTIFY_TEXT" https://api.pushover.net/1/messages.json
Bark curl -fsS --data-urlencode "body=$PI_NOTIFY_TEXT" "https://api.day.app/$BARK_KEY"
Discord curl -fsS --form-string "content=$PI_NOTIFY_TEXT" "$DISCORD_WEBHOOK_URL"
Slack jq -n --arg text "$PI_NOTIFY_TEXT" '{text: $text}' | curl -fsS -H 'Content-Type: application/json' --data-binary @- "$SLACK_WEBHOOK_URL"

Escape " as \" inside JSON. Quote "$PI_NOTIFY_TEXT" in the command.

The command runs in the session directory with your shell, your permissions, and your environment, so configure only commands you trust. Exit code 0 means success; output is discarded. Each send times out after 10 seconds. Keep the command in the foreground: Pi cannot stop a background process when it times out.