Skip to content
Esc
↑↓navigate↵open⌘Jpreview
Start
On this page

Real-Time Notifications

Real-time notifications keep teams informed while an agent runs. You can stream progress to Slack, send email summaries, or call a webhook when milestones complete.

Notification strategies

  • Stream events - forward message_update and tool_end events to a channel for live progress.
  • Session summary - collect output and send one message when the session ends.
  • Alerts - watch for error and permission_request events and notify operators immediately.

Slack notification example

Send notifications from SDK events when you need routing or formatting logic, and use curl when a shell hook is enough.

for await (const event of sdk.streamPrompt({ message: 'Deploy the api service' })) {
  if (event.type === 'session_end') {
    await fetch(process.env.SLACK_WEBHOOK, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ text: `Autohand completed in ${event.duration}ms.` })
    });
  }
}
for await (const event of sdk.streamPrompt({ message: 'Deploy the api service' })) {
  if (event.type === 'session_end') {
    await notifySlack({
      text: `Autohand completed in ${event.duration}ms.`,
      sessionId: event.sessionId
    });
  }
}
async for event in sdk.stream_prompt("Deploy the api service"):
    if event["type"] == "session_end":
        await notify_slack({
            "text": f"Autohand completed in {event['duration']}ms.",
            "session_id": event["session_id"],
        })
events, _ := sdk.StreamPrompt(ctx, "Deploy the api service")
for event := range events {
  if event.Type == "session_end" {
    notifySlack(ctx, fmt.Sprintf("Autohand completed in %dms.", event.Duration))
  }
}
sdk.streamPrompt("Deploy the api service").forEach(event -> {
  if (event.type().equals("session_end")) {
    slack.notify("Autohand completed in " + event.duration() + "ms.");
  }
});
for try await event in sdk.streamPrompt("Deploy the api service") {
    if event.type == .sessionEnd {
        try await slack.notify("Autohand completed in \(event.duration)ms.")
    }
}
curl -X POST "$SLACK_WEBHOOK" \
  -H "Content-Type: application/json" \
  -d '{"text":"Autohand session completed."}'

Hooks versus SDK events

If you only need notifications, configure shell hooks in .autohand/config.json. Use SDK events when you need to transform the payload, route to different channels, or conditionally suppress messages.

Best practices

  • Batch rapid events to avoid rate limits.
  • Include the session ID and a link to full logs in every message.
  • Do not send secrets or file contents in notifications.
  • Provide a quiet mode for sensitive sessions.

Last updated on

Was this helpful?

Send Feedback

Help us improve this documentation page. Your feedback is valuable.

We'll only contact you if we need clarification