Sonar is an open-source self hostable event notification system that helps you monitor your application workflows in real-time through Discord and Telegram.
- Self-Hostable: Sonar is completely open-sourced and self-hostable, you own your own data
- Real-time Notifications: Instant updates about your workflow events
- Multiple Services: Support for both Discord and Telegram
- Type-Safe SDK: Built with TypeScript for reliable integration
- Flexible Workflows: Define custom workflows with event chains
- Rich Notifications: Detailed event information with customizable formatting
- Pause Control: Temporarily pause notifications when needed
- Multiple Projects: Manage multiple projects from one interface
- Event Chaining: Define what happens next after each event
- Custom Callbacks: Execute code after specific events
npm install @sonar/sdk
# or
yarn add @sonar/sdk
# or
pnpm add @sonar/sdk
# or
bun add @sonar/sdk
Add these environment variables to your .env
file:
SONAR_API_KEY=your_api_key
SONAR_BASE_URL=your_api_endpoint
SONAR_PROJECT_ID=your_project_id
import { workflow } from '@sonar/sdk';
import { z } from 'zod';
// Define your workflow events
type UserSignupEvents = {
started: {
data: { email: string; username: string };
};
completed: {
data: { userId: string; email: string };
};
};
// Create a workflow
const signupFlow = workflow<UserSignupEvents>('UserSignup', (wf) => {
wf.on(
'started',
{
description: 'User signup initiated',
severity: 'info',
tags: ['auth', 'signup'],
schema: z.object({
email: z.string().email(),
username: z.string()
})
},
(data) => ({
user: data.username,
email: data.email
}),
{ service: ['Discord', 'Telegram'] }
).next('completed');
});
// Emit events
await signupFlow.emit({
event: 'started',
data: {
email: 'user@example.com',
username: 'newuser'
}
});
- Invite the bot to your server using the provided link
- Use
/connect <project_id> <api_key>
in your desired channel - Use
/help
to see all available commands
- Start a chat with @SonarNotifyBot
- Use
/connect <project_id> <api_key>
to link your project - Use
/help
to see all available commands
Both Discord and Telegram bots support:
/connect
- Link a channel to your project/disconnect
- Remove project link/status
- Check connection status/pause
- Pause notifications temporarily/resume
- Resume notifications/help
- Show all commands
Still a work in progress
See examples directory for more use cases and patterns.
We welcome contributions! See our Contributing Guide for details.
MIT License - see LICENSE for details.