Skip to main content.

Site Map

Site Map



The Notification Service Brick has been developed to provide sending notifications from the system to a user. This includes sending emails and text messages (SMS).

Publish the ServiceBrick.ServiceBus.CreateApplicationEmailEvent or the ServiceBrick.ServiceBus.CreateApplicationSmsEvent to send an email or SMS from a microservice over Service Bus instead of using direct service communication.


  • Normal Startup Extensions for AddBrick, RegisterBrick and StartBrick with a storage provider
  • You must register into dependency injection (AddBrick) an implementation for IEmailProvider and ISmsProvider. We provide implementations for:
    • Email
      • LoggingProvider (Default) - Doesn't send an email, writes it to application logging instead. Included in ServiceBrick.Notification
      • SmtpProvider - Send via a standard SMTP connection. Included in ServiceBrick.Notification
      • Twilio SendGrid - NuGet Package ServiceBrick.Notification.SendGrid
    • Text (SMS)
      • LoggingProvider (Default) - Doesn't send an sms, writes it to application logging instead. Included in ServiceBrick.Notification
      • Twilio - NuGet Package ServiceBrick.Notification.Twilio

Developer Notes

Options are accessed using IOptions<NotificationOptions> from dependency injection.

Service Bus

This service subscribes to the following domain events:

  • ServiceBrick.ServiceBus.CreateApplicationEmailEvent
  • ServiceBrick.ServiceBus.CreateApplicationSmsEvent

Upon receiving these messages, it will store them to the configured storage provider and will eventually be picked up to be processed.

Background Tasks

The ServiceBrick.Notification.NotificationSendTimer runs every 30 seconds and invokes the ServiceBrick.Notification.NotificationSendTask, which is responsible for sending notifications. Using the SenderTypeKey value, it will send the notification to the associated provider. Includes error handling and retries.

Interfaces and Data Transfer Objects

using ServiceBrick.Notification.Api;

public interface IMessageApiService : IApiService<MessageDto> { }   
public interface IMessageApiClient : IApiClient<MessageDto>, IMessageApiService { }
public class MessageDto : DataTransferObject
        public int SenderTypeKey { get; set; }
        public bool IsError { get; set; }
        public bool IsComplete { get; set; }
        public int RetryCount { get; set; }
        public DateTimeOffset FutureProcessDate { get; set; }
        public DateTimeOffset CreateDate { get; set; }
        public DateTimeOffset UpdateDate { get; set; }
        public DateTimeOffset ProcessDate { get; set; }
        public bool IsProcessing { get; set; }
        public virtual bool IsHtml { get; set; }
        public virtual string Priority { get; set; }
        public virtual string Subject { get; set; }
        public virtual string BccAddress { get; set; }
        public virtual string CcAddress { get; set; }
        public virtual string ToAddress { get; set; }
        public virtual string FromAddress { get; set; }
        public virtual string Body { get; set; }
        public virtual string BodyHtml { get; set; }

public class SenderType : DomainType { }

Application Settings

    "ServiceBrick": {
        "Notification": {
            "Client": {
                "ApiConfig": {
                    "ServiceUrl": "https://localhost:7000",
                    "TokenUrl": "https://localhost:7000/api/v1.0/Security/Authentication/AuthenticateUser",
                    "TokenType": "password",
                    "TokenClient": "",
                    "TokenSecret": "mypassword"
            "Options": {
                // If "IsDevelopment" is true, removes all senders and only send to "DevelopmentEmailTo" email address
                "IsDevelopment": false, 
                "DevelopmentEmailTo": "",
                "EmailFromDefault": "",
                "EmailFromDefaultName": "ServiceBrick Email Account",
                // Add additional recipients
                "EmailToAdditional": "",
                "EmailCcAdditional": "",
                "EmailBccAdditional": ""

            // Email Providers
            "Smtp": {
                "EmailServer": "",
                "EmailPort": 443,
                "EmailEnableSsl": true,
                "EmailUsername": "myusername",
                "EmailPassword": "mypassword",
            "SendGrid": {
                "ApiKey": "InsertAPIKeyHere"

            // Storage Providers
                "ConnectionString": ""
                "ConnectionString": ""
                "ConnectionString": "",
                "DatabaseName": ""