Agent results need to reach humans. WebhookDispatcher handles the delivery plumbing — formatting messages for different platforms. AgentNotifier adds agent-specific context and routes to the right channel.
WebhookDispatcher: Platform-Specific Formatting
Each platform has a different JSON structure:
Slack: {"text": "...", "blocks": [...]}
Discord: {"content": "...", "embeds": [...]}
Teams: {"@type": "MessageCard", "sections": [...]}
Generic: {"message": "...", "data": {...}}
Four formatters (SlackFormatter, DiscordFormatter, TeamsFormatter, GenericFormatter) convert a universal alert payload into platform-specific JSON. The dispatcher detects the platform from the webhook URL pattern and applies the right formatter.
AgentNotifier: Context Wrapper
When an agent completes, AgentNotifier enriches the notification:
public function notifyPatchReady(
string $logId,
string $eventType,
array $eventData,
array $patchOrPatches,
bool $isDryRun,
?string $branch,
string $agentName
): void
The notification includes: agent name, event type, severity (with emoji: 🔴 critical, 🟠 high), patch summary (files changed count), branch name, and whether this is a dry run.
Telegram: Interactive Buttons
For Telegram, patches get inline keyboard buttons:
🔧 lukagent — N+1 Fix
Event: luka.n1_detected
Severity: 🟠 high
Branch: autofix/n1-invoices-a3f9d2
Files: 1 modified
[✅ Approve] [❌ Reject]
Tapping "Approve" triggers a callback that merges the branch. Tapping "Reject" deletes it.
Webhooks: Text Summary
For Slack/Discord/Teams, the same information as a formatted text block. No interactive buttons — webhooks are one-way. The admin sees the alert and acts in the web dashboard.
The Routing Decision
Agent with patches → Telegram (interactive) + Webhook (informational)
Agent without patches → Webhook only (informational)
Dry run → Webhook only (no approval needed)
Patches always go to Telegram because they need interactive approval. Non-patch results (analysis, reports) go to webhooks only. Dry runs are logged but don't need human action.
Up Next
Next up: PM Auto-Chain: How a Task Update Triggers an AI Code Review — the full chain from subtask completion to reviewer verdict, pipeline loop-to cycles, and VajbCoder scaffold branch creation.
Comments (0)
No comments yet. Be the first to share your thoughts!
Leave a Comment