WP Webhooks / Docs / fswa_notification_channel_drivers
Filter since v3.3.0

fswa_notification_channel_drivers

Register your own notification channel type — a destination the rule editor offers next to Slack, email and the rest.

$

/ Signature

apply_filters( 'fswa_notification_channel_drivers', $drivers )

/ When it fires

Once per request, the first time the registry is read. Fields typed secret are encrypted at rest and never returned over the API; they arrive decrypted in $secrets at send time. Extend AbstractHttpDriver to get a post() helper with a 10-second timeout and one retry on 429/5xx that honours Retry-After, plus plainText(), truncate() and severity colours.

/ Parameters

NameInTypeReqDescription
$driversparamChannelDriver[]yesThe built-in drivers. Append an object implementing `FlowSystems\WebhookActions\Services\Notifications\Channels\ChannelDriver`: `type()` (a slug), `label()`, `description()`, `fields()` (the form — each field `{key, label, type, required, help, placeholder, default}` with `type` one of `text`, `secret`, `url`, `emails`, `number`, `toggle`, `select`, `textarea`, `credential`) and `send( array $message, array $config, array $secrets ): true|WP_Error`.

/ Returns

ChannelDriver[] The driver list. A driver whose `type()` matches a built-in one replaces it.

/ Examples

A Matrix (Element) channel

use FlowSystems\WebhookActions\Services\Notifications\Channels\AbstractHttpDriver;

class Matrix_Driver extends AbstractHttpDriver {
    public function type(): string  { return 'matrix'; }
    public function label(): string { return 'Matrix'; }
    public function fields(): array {
        return [
            [ 'key' => 'homeserver', 'label' => 'Homeserver URL', 'type' => 'url', 'required' => true, 'placeholder' => 'https://matrix.example.org' ],
            [ 'key' => 'room_id', 'label' => 'Room ID', 'type' => 'text', 'required' => true ],
            [ 'key' => 'access_token', 'label' => 'Access token', 'type' => 'secret', 'required' => true ],
        ];
    }
    public function send( array $message, array $config, array $secrets ): true|\WP_Error {
        $url = rtrim( $config['homeserver'], '/' ) . '/_matrix/client/v3/rooms/' . rawurlencode( $config['room_id'] ) . '/send/m.room.message/' . wp_generate_uuid4();
        $result = $this->post( $url, [ 'msgtype' => 'm.text', 'body' => $this->plainText( $message ) ], [ 'Authorization' => 'Bearer ' . $secrets['access_token'] ], 'PUT' );
        return $this->outcome( $result );
    }
}

add_filter( 'fswa_notification_channel_drivers', function ( array $drivers ) {
    $drivers[] = new Matrix_Driver();
    return $drivers;
} );

/ Related

Ready

Your next automation is
one sentence away.

$ wp plugin install flowsystems-webhook-actions --activate