/notify-hub:notifyhubfrom notify-hub
Provides expert guidance on NotifyHub, a unified Java/Spring Boot notification library with a fluent API for 17 channels including Email, SMS, Slack, Telegram, Discord, and more.
Ships in notify-hub. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in NotifyHub, a unified notification library for Java 17+ and Spring Boot 3.x that provides a single fluent API to send notifications across 17 channels.
NotifyHub eliminates the need for different code per notification channel. One fluent API handles Email, SMS, WhatsApp, Slack, Telegram, Discord, Microsoft Teams, Firebase Push, Webhooks, WebSocket, Google Chat, Twitter/X, LinkedIn, Notion, Twitch, YouTube, and Instagram.
io.github.gabrielbbaldez0.9.0notify-hub/
├── notify-core/ # Core API, interfaces, fluent builder
│ └── io.notifyhub.core
│ ├── NotifyHub.java # Main entry point (fluent API)
│ ├── Notification.java # Immutable notification object
│ ├── Channel.java # Channel enum (EMAIL, SMS, SLACK, ...)
│ ├── Priority.java # URGENT, HIGH, NORMAL, LOW
│ ├── DeliveryReceipt.java # Delivery tracking receipt
│ ├── channel/ # NotificationChannel interface
│ ├── template/ # TemplateEngine, MustacheTemplateEngine
│ ├── retry/ # RetryPolicy (none, fixed, exponential)
│ ├── ratelimit/ # RateLimitConfig, TokenBucketRateLimiter
│ ├── dlq/ # DeadLetter, DeadLetterQueue
│ ├── oauth/ # OAuthTokenManager (auto-refresh)
│ ├── audience/ # Contact, Audience, AudienceManager
│ └── routing/ # NotificationRouter
├── notify-channels/ # One module per channel
│ ├── notify-email/ # SMTP (JavaMail)
│ ├── notify-sms/ # Twilio SMS
│ ├── notify-slack/ # Slack webhooks
│ ├── notify-telegram/ # Telegram Bot API
│ ├── notify-discord/ # Discord webhooks
│ ├── notify-teams/ # Microsoft Teams webhooks
│ ├── notify-push-firebase/ # Firebase Cloud Messaging
│ ├── notify-webhook/ # Generic HTTP webhooks
│ ├── notify-websocket/ # Java WebSocket
│ ├── notify-google-chat/ # Google Chat webhooks
│ ├── notify-twitter/ # Twitter/X API v2
│ ├── notify-linkedin/ # LinkedIn REST API
│ ├── notify-notion/ # Notion Database API
│ ├── notify-twitch/ # Twitch Helix API
│ ├── notify-youtube/ # YouTube Live Chat API
│ └── notify-instagram/ # Instagram Graph API
├── notify-spring-boot-starter/ # Auto-configuration + properties
│ └── io.notifyhub.spring
│ ├── NotifyAutoConfiguration.java # Main auto-config
│ ├── NotifyProperties.java # All Spring Boot properties
│ └── Notify*AutoConfiguration.java # Per-channel auto-configs
├── notify-mcp/ # MCP Server for AI agents (27 tools)
└── notify-demo/ # Demo application
// Single recipient
notify.to(user) // Notifiable object
notify.to("[email protected]") // Email string
notify.toPhone("+5548999999999") // Phone number
// Batch recipients
notify.toAll(List.of("[email protected]", "[email protected]"))
notify.toAllNotifiable(List.of(user1, user2))
notify.toAudience("premium-users")
// Auto-route via preferred channels
notify.notify(user)
notify.to(user)
.via(Channel.EMAIL) // Primary channel
.fallback(Channel.SMS) // Fallback if primary fails
.fallback(Channel.WHATSAPP) // Second fallback
.priority(Priority.HIGH) // URGENT, HIGH, NORMAL, LOW
.subject("Order confirmed") // Subject (email/push/teams)
.content("Your order #123 is ready") // Plain text body
.template("order-confirmed") // OR use Mustache template
.templateVersion("v2") // Template version (A/B testing)
.param("orderId", order.getId()) // Template parameter
.params(Map.of("k", "v")) // Bulk template params
.locale(Locale.PT_BR) // i18n locale
.attach(file) // File attachment (email)
.retry(3) // Override retry count
.deduplicationKey("order-123") // Prevent duplicates
.metadata("traceId", "abc-123") // Custom metadata
.send(); // Execute synchronously
.send() // Sync, uses fallback chain
.sendAll() // Sync, sends to ALL .via() channels
.sendAsync() // Async (CompletableFuture<Void>)
.sendAllAsync() // Async to all channels
.sendTracked() // Returns DeliveryReceipt
.sendAllTracked() // Returns List<DeliveryReceipt>
.schedule(Duration.ofMinutes(30)) // Schedule for later
.scheduleAt(Instant.parse("...")) // Schedule at specific time
Channel.EMAIL, Channel.SMS, Channel.WHATSAPP, Channel.PUSH
Channel.SLACK, Channel.TELEGRAM, Channel.DISCORD, Channel.TEAMS
Channel.WEBSOCKET, Channel.GOOGLE_CHAT
Channel.TWITTER, Channel.LINKEDIN, Channel.NOTION
Channel.TWITCH, Channel.YOUTUBE, Channel.INSTAGRAM
Channel.custom("pagerduty") // Custom channels
Priority.URGENT // Bypasses rate limiting
Priority.HIGH
Priority.NORMAL // Default
Priority.LOW
NotifyHub hub = NotifyHub.builder()
.channel(emailChannel)
.channel(slackChannel)
.channels(List.of(smsChannel, pushChannel))
.templateEngine(new MustacheTemplateEngine())
.defaultRetryPolicy(RetryPolicy.exponential(3))
.listener(myListener)
.executor(Executors.newFixedThreadPool(4))
.scheduler(Executors.newScheduledThreadPool(2))
.tracker(new InMemoryNotificationTracker())
.rateLimiter(new TokenBucketRateLimiter(config))
.deadLetterQueue(new InMemoryDeadLetterQueue())
.router(myRouter)
.deduplicationStore(new InMemoryDeduplicationStore())
.auditLog(new InMemoryAuditLog())
.audienceManager(new AudienceManager(contactRepo))
.build();
SmtpConfig.builder()
.host("smtp.gmail.com").port(587)
.username("user").password("pass")
.from("[email protected]").fromName("MyApp")
.tls(true)
.build();
TwilioConfig.builder()
.accountSid("AC...").authToken("token")
.fromNumber("+15551234567")
.build();
SlackConfig.builder()
.webhookUrl("https://hooks.slack.com/services/...")
.recipients(Map.of("engineering", "https://hooks.slack.com/..."))
.build();
TelegramConfig.builder()
.botToken("123456:ABC-DEF").chatId("987654321")
.recipients(Map.of("admin", "123456789"))
.build();
DiscordConfig.builder()
.webhookUrl("https://discord.com/api/webhooks/...")
.username("NotifyBot").avatarUrl("https://...")
.recipients(Map.of("alerts", "https://discord.com/api/webhooks/..."))
.build();
TeamsConfig.builder()
.webhookUrl("https://outlook.office.com/webhook/...")
.recipients(Map.of("devops", "https://outlook.office.com/webhook/..."))
.build();
FirebasePushConfig.builder()
.serverKey("AAAA...").build();
WebSocketConfig.builder()
.uri("wss://ws.example.com/notifications")
.reconnectEnabled(true).reconnectDelayMs(3000).maxReconnectAttempts(10)
.headers(Map.of("Authorization", "Bearer token"))
.messageFormat("json")
.build();
GoogleChatConfig.builder()
.webhookUrl("https://chat.googleapis.com/v1/spaces/...")
.recipients(Map.of("team", "https://chat.googleapis.com/..."))
.build();
TwitterConfig.builder()
.apiKey("key").apiSecret("secret")
.accessToken("token").accessTokenSecret("tokenSecret")
.build();
LinkedInConfig.builder()
.accessToken("token")
.authorId("urn:li:person:abc123")
.build();
NotionConfig.builder()
.apiKey("secret_...").databaseId("db-id")
.recipients(Map.of("tasks", "another-db-id"))
.build();
TwitchConfig.builder()
.clientId("tyxy0tn8...")
.accessToken("ck6uie0g...") // Seed token
.refreshToken("pmn0lc2x...") // Optional: enables auto-refresh
.clientSecret("wku9i8gu...") // Required with refreshToken
.broadcasterId("836211004")
.senderId("836211004")
.build();
// getAccessToken() auto-renews 5 minutes before expiry
YouTubeConfig.builder()
.accessToken("ya29.a0...") // Seed token
.refreshToken("1//0eXyz...") // Optional: enables auto-refresh
.clientId("123.apps.google...") // Required with refreshToken
.clientSecret("GOCSPX-...") // Required with refreshToken
.channelId("UC...")
.liveChatId("Cg0KC...")
.build();
// Token auto-refreshes via Google OAuth2 endpoint
InstagramConfig.builder()
.accessToken("IGQ...")
.igUserId("17841...")
.recipients(Map.of("support", "user-id"))
.build();
WebhookConfig.builder()
.name("pagerduty")
.url("https://events.pagerduty.com/v2/enqueue")
.method("POST")
.headers(Map.of("Authorization", "Token token=..."))
.payloadTemplate("{\"routing_key\":\"R0...\",\"event_action\":\"trigger\",\"payload\":{\"summary\":\"{{content}}\"}}")
.build();
NotifyHub supports automatic OAuth 2.0 token refresh for YouTube and Twitch. The OAuthTokenManager is thread-safe using ReentrantReadWriteLock and proactively refreshes tokens 5 minutes before expiry.
OAuthTokenManager manager = OAuthTokenManager.builder()
.tokenEndpoint("https://oauth2.googleapis.com/token")
.refreshToken("1//0eXyz...")
.clientId("client-id")
.clientSecret("client-secret")
.initialAccessToken("ya29...") // Optional seed token
.refreshBufferSeconds(300) // Default: 300 (5 min before expiry)
.timeoutSeconds(10) // HTTP timeout
.build();
String token = manager.getAccessToken(); // Auto-refresh if needed
manager.forceRefresh(); // Force refresh (e.g., after 401)
Token refresh is enabled automatically when refreshToken + clientSecret (and clientId for YouTube) are provided in the channel config. If only a static accessToken is set, behavior is backward-compatible with no refresh.
Place templates in src/main/resources/templates/notify/:
templates/notify/
├── order-confirmed/
│ ├── html.mustache # Email HTML variant
│ └── txt.mustache # SMS/WhatsApp text variant
├── welcome/
│ ├── html.mustache
│ └── txt.mustache
└── alert/
└── txt.mustache
Usage:
notify.to(user)
.via(Channel.EMAIL)
.template("order-confirmed")
.param("customerName", "Gabriel")
.param("orderId", "ORD-123")
.locale(Locale.PT_BR) // i18n support
.templateVersion("v2") // A/B testing
.send();
The TemplateEngine interface:
public interface TemplateEngine {
String render(String templateName, String variant, Map<String, Object> params);
String render(String templateName, String variant, Map<String, Object> params, Locale locale);
boolean exists(String templateName, String variant);
}
Built-in implementations: MustacheTemplateEngine, VersionedTemplateEngine.
RetryPolicy.none() // Fail immediately
RetryPolicy.fixed(3, Duration.ofSeconds(2)) // 3 attempts, 2s delay
RetryPolicy.exponential(3) // 3 attempts, 1s/2s/4s backoff
RetryPolicy.exponential(5, Duration.ofMillis(500)) // Custom initial delay
Methods: getMaxAttempts(), getInitialDelay(), getStrategy() (NONE/FIXED/EXPONENTIAL), getDelayForAttempt(int), shouldRetry().
Built-in TokenBucketRateLimiter with per-channel API-aware presets:
| Channel | Limit | Window |
|---|---|---|
| YouTube | 180 requests | 1 day |
| Twitch | 20 requests | 30 seconds |
| Twitter/X | 300 requests | 3 hours |
| Slack | 1 request | 1 second |
| Telegram | 30 requests | 1 second |
| Discord | 30 requests | 1 minute |
| 100 requests | 1 day | |
| 200 requests | 1 hour | |
| Google Chat | 60 requests | 1 minute |
RateLimitConfig.youtube() // Factory method per channel
RateLimitConfig.forChannel("twitch") // Lookup by name
RateLimitConfig.allDefaults() // Map of all presets
RateLimitConfig.perSecond(10) // Custom
RateLimitConfig.perMinute(60) // Custom
Priority.URGENT bypasses rate limiting.
DeliveryReceipt receipt = notify.to(user)
.via(Channel.EMAIL)
.template("welcome")
.sendTracked();
receipt.getId(); // UUID
receipt.getChannelName(); // "email"
receipt.getRecipient(); // "[email protected]"
receipt.getStatus(); // PENDING, SCHEDULED, SENT, FAILED, CANCELLED
receipt.getTimestamp(); // Instant
receipt.getErrorMessage(); // null or error details
Failed notifications (after all retries) are captured in the DLQ:
DeadLetter.builder()
.channelName("email")
.recipient("[email protected]")
.subject("Welcome")
.content("Hello!")
.errorMessage("Connection refused")
.attemptCount(3)
.build();
Access: hub.getDeadLetterQueue().findAll().
// Create contacts
Contact vip = Contact.builder()
.name("Gabriel").email("[email protected]").phone("+5548999999999")
.tag("vip").tag("plan:premium")
.metadata("region", "south")
.build();
// Create audience (AND logic on tags)
hub.getAudienceManager().createAudience("premium-users", Set.of("vip", "plan:premium"));
// Send to audience
notify.toAudience("premium-users")
.via(Channel.EMAIL)
.template("exclusive-offer")
.send();
Implement on your domain objects:
public class User implements Notifiable {
public String getNotifyEmail() { return email; }
public String getNotifyPhone() { return phone; }
public String getNotifyPushToken(){ return pushToken; }
public String getNotifyName() { return name; }
public List<Channel> getPreferredChannels() {
return List.of(Channel.EMAIL, Channel.PUSH);
}
}
Implement NotificationChannel:
public class PagerDutyChannel implements NotificationChannel {
public String getName() { return "pagerduty"; }
public boolean isAvailable() { return apiKey != null; }
public void send(Notification notification) throws NotificationSendException {
// Your implementation
}
}
Register: hub.registerChannel(new PagerDutyChannel(config)) or as a Spring @Bean.
public class MyListener implements NotificationListener {
public void onSuccess(String channel, String template) { /* ... */ }
public void onFailure(String channel, String template, Exception e) { /* ... */ }
public void onScheduled(String channel, String recipient, Duration delay) { /* ... */ }
public void onCancelled(String channel, String recipient) { /* ... */ }
}
<dependency>
<groupId>io.github.gabrielbbaldez</groupId>
<artifactId>notify-spring-boot-starter</artifactId>
<version>0.9.0</version>
</dependency>
Optional channel modules (add as needed):
<artifactId>notify-sms</artifactId> <!-- SMS + WhatsApp -->
<artifactId>notify-slack</artifactId>
<artifactId>notify-telegram</artifactId>
<artifactId>notify-discord</artifactId>
<artifactId>notify-teams</artifactId>
<artifactId>notify-push-firebase</artifactId>
<artifactId>notify-webhook</artifactId>
<artifactId>notify-websocket</artifactId>
<artifactId>notify-google-chat</artifactId>
<artifactId>notify-twitter</artifactId>
<artifactId>notify-linkedin</artifactId>
<artifactId>notify-notion</artifactId>
<artifactId>notify-twitch</artifactId>
<artifactId>notify-youtube</artifactId>
<artifactId>notify-instagram</artifactId>
application.yml Referencenotify:
channels:
email:
host: smtp.gmail.com
port: 587
username: ${GMAIL_USER}
password: ${GMAIL_PASS}
from: [email protected]
from-name: MyApp
tls: true
# ssl: false
sms:
account-sid: ${TWILIO_ACCOUNT_SID}
auth-token: ${TWILIO_AUTH_TOKEN}
from-number: "+15551234567"
whatsapp:
account-sid: ${TWILIO_ACCOUNT_SID}
auth-token: ${TWILIO_AUTH_TOKEN}
from-number: "+14155238886"
slack:
webhook-url: ${SLACK_WEBHOOK_URL}
recipients:
engineering: "https://hooks.slack.com/services/..."
alerts: "https://hooks.slack.com/services/..."
telegram:
bot-token: ${TELEGRAM_BOT_TOKEN}
chat-id: ${TELEGRAM_CHAT_ID}
recipients:
admin: "123456789"
discord:
webhook-url: ${DISCORD_WEBHOOK_URL}
username: NotifyBot
avatar-url: "https://example.com/avatar.png"
recipients:
alerts: "https://discord.com/api/webhooks/..."
teams:
webhook-url: ${TEAMS_WEBHOOK_URL}
recipients:
devops: "https://outlook.office.com/webhook/..."
push:
server-key: ${FIREBASE_SERVER_KEY}
websocket:
uri: wss://ws.example.com/notifications
reconnect-enabled: true
reconnect-delay-ms: 3000
max-reconnect-attempts: 10
headers:
Authorization: "Bearer ${WS_TOKEN}"
google-chat:
webhook-url: ${GOOGLE_CHAT_WEBHOOK_URL}
recipients:
team: "https://chat.googleapis.com/..."
twitter:
api-key: ${TWITTER_API_KEY}
api-secret: ${TWITTER_API_SECRET}
access-token: ${TWITTER_ACCESS_TOKEN}
access-token-secret: ${TWITTER_ACCESS_TOKEN_SECRET}
linkedin:
access-token: ${LINKEDIN_ACCESS_TOKEN}
author-id: "urn:li:person:abc123"
notion:
api-key: ${NOTION_API_KEY}
database-id: ${NOTION_DATABASE_ID}
twitch:
client-id: ${TWITCH_CLIENT_ID}
access-token: ${TWITCH_ACCESS_TOKEN}
refresh-token: ${TWITCH_REFRESH_TOKEN} # Optional: auto-refresh
client-secret: ${TWITCH_CLIENT_SECRET} # Required with refresh-token
broadcaster-id: "836211004"
sender-id: "836211004"
youtube:
access-token: ${YOUTUBE_ACCESS_TOKEN}
refresh-token: ${YOUTUBE_REFRESH_TOKEN} # Optional: auto-refresh
client-id: ${YOUTUBE_CLIENT_ID} # Required with refresh-token
client-secret: ${YOUTUBE_CLIENT_SECRET} # Required with refresh-token
channel-id: ${YOUTUBE_CHANNEL_ID}
live-chat-id: ${YOUTUBE_LIVE_CHAT_ID}
instagram:
access-token: ${INSTAGRAM_ACCESS_TOKEN}
ig-user-id: ${INSTAGRAM_USER_ID}
webhooks:
- name: pagerduty
url: "https://events.pagerduty.com/v2/enqueue"
method: POST
headers:
Authorization: "Token token=${PAGERDUTY_TOKEN}"
payload-template: '{"routing_key":"{{routingKey}}","event_action":"trigger","payload":{"summary":"{{content}}"}}'
retry:
max-attempts: 3 # Default: 1
strategy: exponential # none, fixed, exponential
scheduling:
enabled: true
pool-size: 2
tracking:
enabled: true # Enable delivery receipts
type: memory # memory (default) or jpa
dlq-enabled: true # Enable dead letter queue
events:
enabled: true # Spring event publishing
rate-limit:
enabled: true # Enable rate limiting
use-defaults: true # Use API-aware presets per channel
max-requests: 100 # Global default
window: 60s # Global default window
channels: # Per-channel overrides
slack:
max-requests: 2
window: 1s
deduplication:
enabled: true
ttl: 24h
strategy: content-hash # content-hash or explicit-key
audit:
enabled: true
type: memory # memory (default) or jpa
audience:
enabled: true
status-webhook:
url: "https://myapp.com/notify/status"
timeout-ms: 10000
signing-secret: ${WEBHOOK_SIGNING_SECRET}
headers:
X-Custom: value
@Service
public class MyService {
private final NotifyHub notify;
public MyService(NotifyHub notify) { this.notify = notify; }
}
Auto-configured channels appear as beans. Only channels with their required properties set are activated (e.g., email requires notify.channels.email.host).
NotifyHub includes a standalone MCP (Model Context Protocol) server with 27 tools for AI agent integration. Run via:
java -jar notify-mcp/target/notify-mcp-0.9.0.jar
Channel-Specific Sending:
send_email — Send via SMTPsend_sms — Send via Twiliosend_whatsapp — Send via Twilio WhatsAppsend_slack — Send via webhooksend_telegram — Send via Bot APIsend_discord — Send via webhooksend_teams — Send via webhooksend_google_chat — Send via webhooksend_push — Firebase Cloud Messagingsend_twitter — Twitter/X API v2send_linkedin — LinkedIn REST APIsend_notion — Notion Database APIsend_twitch — Twitch Helix API chat messagesend_youtube — YouTube Live Chat messagesend_instagram — Instagram Graph APIUnified & Batch:
send_notification — Send via any channel (unified)send_batch — Same message to multiple recipientssend_multi_channel — Same message across multiple channelssend_to_audience — Send to a named audienceContact & Audience Management:
create_contact — Create contact with tagslist_contacts — List/filter contactscreate_audience — Create audience by tag filterlist_audiences — List audiencesMonitoring & Analytics:
list_channels — List configured channels and availabilitylist_delivery_receipts — View delivery historylist_dead_letters — View failed notifications (DLQ)get_analytics — Delivery analytics and statsnotify-channels/notify-{name}/ with Maven moduleNotificationChannel interface (getName(), isAvailable(), send()){Name}Config with builder patternNotify{Name}AutoConfiguration in notify-spring-boot-starterNotifyProperties.java inner classspring.factories or @AutoConfigurationNotificationSendException — thrown by channels on send failureOAuthTokenRefreshException — thrown when token refresh failsRateLimitExceededException — thrown when rate limit exceededTemplateNotFoundException — thrown when template not foundNotifyHub is thread-safe and designed for singleton usageOAuthTokenManager uses ReentrantReadWriteLock for concurrent token accessTokenBucketRateLimiter uses ConcurrentHashMap for per-channel buckets@DisplayName annotationsIllegalArgumentExceptionmvn test (all modules) or mvn test -pl notify-core (specific module)notify.to(user)
.via(Channel.WHATSAPP).fallback(Channel.SMS).fallback(Channel.EMAIL)
.template("payment-reminder")
.param("amount", "R$ 150,00")
.send();
notify.to(user)
.via(Channel.EMAIL).via(Channel.SLACK).via(Channel.TEAMS)
.subject("Security Alert")
.content("Login from new device detected")
.sendAll();
notify.toAudience("premium-users")
.via(Channel.EMAIL)
.template("exclusive-offer")
.param("discount", "30%")
.send();
notify.to(user)
.via(Channel.PUSH)
.content("Don't forget your appointment tomorrow!")
.schedule(Duration.ofHours(24));
CompletableFuture<Void> future = notify.to(user)
.via(Channel.EMAIL)
.template("invoice")
.param("invoiceId", "INV-456")
.sendAsync();
future.thenRun(() -> log.info("Invoice email sent"));
// Send chat message
notify.to("Cg0KC...liveChatId")
.via(Channel.YOUTUBE)
.content("Welcome to the stream!")
.send();
// YouTube supports live chat messages to active streams
notify.to("broadcaster-id")
.via(Channel.TWITCH)
.content("Hello chat! PogChamp")
.send();
notify.to("recipient-user-id")
.via(Channel.INSTAGRAM)
.content("Thanks for your order!")
.send();
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: mcpServers: Invalid string: must start with "./"
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.