x-pack/platform/plugins/shared/notifications/README.mdx
The Notifications plugin provides a set of services to help Solutions and plugins send notifications to users.
The start function exposes the following interface:
isEmailServiceAvailable(): boolean:
A function to check whether the deployment is properly configured and the EmailService can be correctly retrieved.getEmailService(): EmailService:To use the exposed plugin start contract:
notifications is in your requiredPlugins in the kibana.jsonc file:// <plugin>/kibana.jsonc
{
"id": "...",
"requiredPlugins": ["notifications"]
}
// <plugin>/server/plugin.ts
import { NotificationsPluginStart } from '../notifications/server`;
interface MyPluginStartDeps {
notifications?: NotificationsPluginStart;
}
class MyPlugin {
public start(
core: CoreStart,
{ notifications }: MyPluginStartDeps
) {
if (notifications.isEmailServiceAvailable()) {
const emailService = notifications.getEmailService();
emailService.sendPlainTextEmail({
to: 'foo@bar.com',
subject: 'Some subject',
message: 'Hello world!',
});
}
...
}
}
This plugin currently depends on the 'actions' plugin, as it uses Connectors under the hood.
Note also that for each notification channel the corresponding connector must be preconfigured. E.g. to enable email notifications, an Email connector must exist in the system.
Once the appropriate connectors are preconfigured in kibana.yaml, you can configure the 'notifications' plugin by adding:
notifications:
connectors:
default:
email: elastic-cloud-email # The identifier of the configured connector