# Extending: alert channel

> The NotificationChannelContract interface behind Slack, Discord and Telegram — and why it cannot yet be registered from outside the plugin.

A notification channel is anything that can send a delivery-failure alert and describe its own
settings to the admin UI. Slack, Discord and Telegram are each one implementation of
`NotificationChannelContract`.

## The contract

```php
namespace BooleanSmtp\Contracts;

interface NotificationChannelContract
{
    public function getIdentifier(): string;
    public function getName(): string;
    public function send( string $message, array $settings, array $context = [] ): bool;
    public function validateSettings( array $settings ): array;
    public function getSettingsSchema(): array;
}
```

| Method | Returns | Purpose |
| --- | --- | --- |
| `getIdentifier()` | `string` | The unique channel type — `slack`, `discord`, `telegram`. |
| `getName()` | `string` | The display name shown in the admin UI. |
| `send($message, $settings, $context)` | `bool` | Deliver the alert; `true` when it was accepted for delivery. |
| `validateSettings($settings)` | `array<string, string>` | Validation errors keyed by field name. |
| `getSettingsSchema()` | `array<string, array{type, label, required}>` | Field definitions the admin UI's channel form renders from. |

```php
use BooleanSmtp\Contracts\NotificationChannelContract;

class WebhookChannel implements NotificationChannelContract {
    public function getIdentifier(): string { return 'webhook'; }
    public function getName(): string { return 'Generic Webhook'; }
    public function send( string $message, array $settings, array $context = [] ): bool {
        $response = wp_remote_post( $settings['url'] ?? '', [ 'body' => wp_json_encode( [ 'text' => $message ] ) ] );
        return ! is_wp_error( $response );
    }
    public function validateSettings( array $settings ): array { return []; }
    public function getSettingsSchema(): array { return []; }
}
```

## There is currently no filter to register one

Unlike transports (`boolean_smtp_transports`), the map of available channel types is a plain
PHP array in the plugin's own `config/notifications.php` — `NotificationManager` reads it once, at
construction, with no filter over it:

```php
// config/notifications.php
'channels' => [
    'telegram' => \BooleanSmtp\Services\Notification\Channels\TelegramChannel::class,
    'slack'    => \BooleanSmtp\Services\Notification\Channels\SlackChannel::class,
    'discord'  => \BooleanSmtp\Services\Notification\Channels\DiscordChannel::class,
],
```

<Aside type="caution" title="Implementing the contract is not enough">
	A class that implements `NotificationChannelContract` today has no way to reach `NotificationManager` from outside the
	plugin — there is no `boolean_smtp_notification_channels`-style filter over this config. If you need a fourth channel,
	the options are: fork the config array in a custom build, ask BooleanPress to add a registration filter, or drive the
	same outcome from your own code by hooking a delivery-failure action (
	[`boolean_smtp_email_delivery_failed_final`](/hooks/boolean_smtp_email_delivery_failed_final/)) directly instead of
	going through the channel system at all.
</Aside>

## Next steps

- [Custom transport](/extending/custom-transport/) — the equivalent contract that *is* filterable today.
- [Hooks: notifications](/hooks/notifications/) — the payload filters for the three built-in channels.
