Gemini CLI
Get notified when Gemini CLI finishes a response or needs tool permission. Gemini CLI hooks (AfterAgent, Notification) that send to Slack, Telegram, or SMS.
Gemini CLI runs commands on agent events through hooks. Two events matter for notifications:
AfterAgent- the agent finished a response.Notification- Gemini CLI needs your attention, for example to approve a tool (notification_typeisToolPermission).
1. Create the hook script
#!/usr/bin/env bash
# Forwards Gemini CLI AfterAgent and Notification hook events to Alphorn.
jq -c '{
title: ("Gemini CLI - " + (.cwd | split("/") | last)),
message: (if .hook_event_name == "Notification"
then (.message // "Needs your attention")
else (.prompt_response // "Finished") end),
priority: (if .hook_event_name == "Notification" then 4 else 2 end),
tags: ["ai-agent", "gemini-cli",
(if .hook_event_name == "Notification" then "permission" else "completed" end)]
}' | curl -fsS --max-time 5 -X POST https://app.alphorn.dev/n/V1StGXR8_Z5jdHi6B-myT \
-H "Authorization: Bearer $ALPHORN_API_KEY" \
-H "Content-Type: application/json" \
-d @- > /dev/null
exit 0chmod +x ~/.gemini/hooks/alphorn-notify.shThe script prints nothing and exits 0. Gemini CLI parses the output of a successful hook as JSON, and exit code 2 blocks.
2. Register the hooks
{
"hooks": {
"AfterAgent": [
{
"matcher": "*",
"hooks": [
{ "name": "alphorn-done", "type": "command", "command": "~/.gemini/hooks/alphorn-notify.sh", "timeout": 10000 }
]
}
],
"Notification": [
{
"matcher": "*",
"hooks": [
{ "name": "alphorn-input", "type": "command", "command": "~/.gemini/hooks/alphorn-notify.sh", "timeout": 10000 }
]
}
]
}
}timeout is in milliseconds in Gemini CLI. Use .gemini/settings.json in a project to enable the hooks only there. ALPHORN_API_KEY must be set in the environment Gemini CLI runs in. In some older Gemini CLI versions hooks had to be enabled in settings.json first, so if they never fire, update Gemini CLI or check its hooks docs for your version.
Event fields
| Event | Useful fields |
|---|---|
| All | session_id, cwd, hook_event_name, timestamp |
AfterAgent | prompt, prompt_response (the agent's final text) |
Notification | notification_type, message, details |
See AI Agent Notifications for routing conventions and an AGENTS.md snippet that lets the agent send notifications on its own.
Cursor
Get notified when a Cursor agent run completes, is aborted, or fails. A Cursor stop hook in hooks.json that sends to Slack, Telegram, SMS, or email.
Aider
Get notified when Aider finishes a response and waits for input. Configure notifications-command in .aider.conf.yml to send to Slack, Telegram, or SMS.