Class EmailNotificationChannel

java.lang.Object
com.chatmotorapi.api.notify.EmailNotificationChannel
All Implemented Interfaces:
NotificationChannel

public class EmailNotificationChannel
extends Object
implements NotificationChannel

The EmailNotificationChannel class handles sending emails as part of response post-treatment processes. It provides methods to send emails with or without attachments either synchronously or asynchronously, depending on the specified ExecutionMode.

Usage

To create an instance of EmailNotificationChannel, use the nested EmailNotificationChannel.Builder class. The following fields are required:

  • smtpHost: The SMTP server host address.
  • smtpPort: The SMTP server port number.
  • smtpUsername: The username for SMTP authentication.
  • smtpPassword: The password for SMTP authentication.
  • fromAddress: The sender's email address.
  • toAddress: The recipient's email address.
  • subject: The subject of the email.
  • message: The HTML content of the email message.

Optional field:

  • logger: A custom Logger instance for logging operations. If not provided, a default logger will be used.

Example:


 EmailNotificationChannel emailNotificationChannel = new EmailNotificationChannel.Builder()
     .chatMotor(chatmotor)
     .smtpHost("smtp.example.com")
     .smtpPort(587)
     .smtpUsername("your-username")
     .smtpPassword("your-password")
     .fromAddress("from@example.com")
     .toAddress("to@example.com")
     .subject("Email Subject")
     .message("<h1>Hello World</h1>")
     .logger(LoggerFactory.getLogger(YourClass.class))
     .build();
 

After building the instance, you can use the notifyDocumentAvailable and dispatchDocument methods to send emails with or without attachments.

See Also:
EmailNotificationChannel.Builder
  • Method Details

    • notifyDocumentAvailable

      public MotorNotifyResponse notifyDocumentAvailable​(String filePath, ExecutionMode mode)
      Description copied from interface: NotificationChannel
      Notifies the user that a response document is available.
      Specified by:
      notifyDocumentAvailable in interface NotificationChannel
      Parameters:
      filePath - the file path of the response document that is available
      mode - the execution mode, either synchronous (SYNC) or asynchronous (ASYNC)
      Returns:
      a MotorNotifyResponse object containing the result of the notification process
    • dispatchDocument

      public MotorNotifyResponse dispatchDocument​(String filePath, ExecutionMode mode)
      Description copied from interface: NotificationChannel
      Sends the generated response document to the user.
      Specified by:
      dispatchDocument in interface NotificationChannel
      Parameters:
      filePath - the file path of the response document to be sent
      mode - the execution mode, either synchronous (SYNC) or asynchronous (ASYNC)
      Returns:
      a MotorNotifyResponse object containing the result of the document dispatch process