Skip to content

Notifications

Use @stendar/notifications to route high-signal events to external channels.

  • TelegramNotifier (botToken, chatId)
  • DiscordNotifier (webhookUrl)
  • WebhookNotifier (url, optional headers, optional HMAC secret)

All notifiers support:

  • events: list of RuntimeEvents to subscribe to
  • minSeverity: info | warn | error
import { TypedEmitter, type RuntimeEvents } from '@stendar/core';
import { TelegramNotifier } from '@stendar/notifications';
const events = new TypedEmitter<RuntimeEvents>();
const telegram = new TelegramNotifier({
botToken: process.env.TELEGRAM_BOT_TOKEN!,
chatId: process.env.TELEGRAM_CHAT_ID!,
minSeverity: 'warn',
events: ['runtime:error', 'strategy:approval_required', 'strategy:circuit_breaker'],
});
telegram.subscribe(events);

Add TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID to your .env file (see Installation).

DeFiRuntime exposes runtime.on(...); bridge those callbacks into your shared emitter:

runtime.on('runtime:error', (error) => events.emit('runtime:error', error));
runtime.on('policy:decision', (decision, intent) =>
events.emit('policy:decision', decision, intent),
);
runtime.on('tx:confirmed', (confirmation) =>
events.emit('tx:confirmed', confirmation),
);

When using WebhookNotifier with secret, payloads include:

  • X-Stendar-Signature: sha256=<hex-digest>

Use this for signature verification in your receiving service.

Pair this with Security model for production operations.