Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 56 additions & 7 deletions src/scitex/notify/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# scitex.notify

Multi-backend notification system for SciTeX. Sends alerts via audio (TTS), phone calls (Twilio), email, desktop notifications, Emacs, browser popups, and webhooks.
Multi-backend notification system for SciTeX. Sends alerts via audio (TTS), phone calls (Twilio), SMS, email, desktop notifications, Emacs, browser popups, and webhooks.

## Quick Start

Expand All @@ -13,6 +13,9 @@ scitex.notify.alert("Task complete!")
# Phone call via Twilio
scitex.notify.call("Wake up! Your experiment finished.")

# SMS via Twilio
scitex.notify.sms("Build finished!")

# Specify backend explicitly
scitex.notify.alert("Error in pipeline", backend="email", level="error")

Expand All @@ -29,7 +32,7 @@ scitex.notify.available_backends()
| Backend | Description | Requirements |
|---------|-------------|--------------|
| `audio` | Text-to-Speech | `scitex-audio` package |
| `twilio` | Phone call | Twilio account + env vars |
| `twilio` | Phone call / SMS | Twilio account + env vars |
| `email` | SMTP email | SMTP server config |
| `emacs` | Minibuffer message | Running Emacs server |
| `desktop` | System notification | Windows/macOS |
Expand Down Expand Up @@ -71,6 +74,31 @@ To receive calls while in Do Not Disturb / silent mode:
2. **Settings -> Focus -> Do Not Disturb -> Allow Repeated Calls** -> ON
3. Use `repeat=2` -- the second call within 3 minutes bypasses silent mode

## SMS (Twilio)

Uses the same Twilio env vars as phone calls.

```python
import scitex

# Simple SMS
scitex.notify.sms("Build finished!")

# With title prefix
scitex.notify.sms("Pipeline error on node 3", title="SciTeX Alert")

# Override destination
scitex.notify.sms("Urgent!", to_number="+61400000000")
```

CLI:

```bash
scitex notify sms "Build finished!"
scitex notify sms "Alert!" --to +61400000000
scitex notify sms "Error" --title "SciTeX"
```

## Configuration

### Environment Variables
Expand Down Expand Up @@ -135,22 +163,43 @@ scitex.notify.call(
**kwargs,
) -> bool

# Send SMS (no fallback)
scitex.notify.sms(
message: str,
title: str = None, # Prepended to message
to_number: str = None, # Override default
**kwargs,
) -> bool

# Async versions
await scitex.notify.alert_async(...)
await scitex.notify.call_async(...)
await scitex.notify.sms_async(...)

# List available backends
scitex.notify.available_backends() -> list[str]
```

## CLI Commands

```bash
scitex notify send "Task complete!" # Auto-fallback
scitex notify send "Error" --backend email --level error # Specific backend
scitex notify call "Wake up!" --repeat 2 # Phone call
scitex notify sms "Build finished!" # SMS
scitex notify backends # List backends
scitex notify config # Show config
scitex notify --help-recursive # All help
```

## MCP Tools

Available via `scitex mcp serve`:

| Tool | Description |
|------|-------------|
| `notify` | Send notification via backend(s) |
| `notify_by_level` | Send using level-configured backends |
| `list_notification_backends` | List all backends and status |
| `available_notification_backends` | List working backends |
| `get_notification_config` | Get current configuration |
| `notify_send` | Send notification via backend(s) |
| `notify_call` | Make a phone call via Twilio |
| `notify_sms` | Send an SMS via Twilio |
| `notify_backends` | List all backends and availability |
| `notify_config` | Get current configuration |
2 changes: 1 addition & 1 deletion src/scitex/notify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def alert_async(
if name not in available:
continue
try:
b = _get_backend(name, **kwargs)
b = _get_backend(name)
result = await b.send(message, title=title, level=lvl, **kwargs)
if result.success:
return True
Expand Down
8 changes: 4 additions & 4 deletions src/scitex/notify/_backends/_twilio.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ async def send(
**kwargs,
) -> NotifyResult:
try:
to_number = kwargs.get("to_number", self.to_number)
from_number = kwargs.get("from_number", self.from_number)
flow_sid = kwargs.get("flow_sid", self.flow_sid)
repeat = kwargs.get("repeat", self.repeat)
to_number = kwargs.get("to_number") or self.to_number
from_number = kwargs.get("from_number") or self.from_number
flow_sid = kwargs.get("flow_sid") or self.flow_sid
repeat = kwargs.get("repeat") or self.repeat

if not all([self.account_sid, self.auth_token, from_number, to_number]):
raise ValueError(
Expand Down
Loading