Class SlackNotificationChannel

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

public class SlackNotificationChannel
extends Object
implements NotificationChannel

The SlackNotificationChannel class handles posting messages and files to a specified Slack channel as part of response post-treatment processes. It provides methods to send messages and files either synchronously or asynchronously, depending on the specified ExecutionMode.

Usage

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

  • token: Your Slack API token for authentication.
  • channel: The Slack channel ID where messages and files will be sent.

Optional field:

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

Example:


 SlackNotificationChannel slackNotificationChannel = new SlackNotificationChannel.Builder()
     .chatMotor(chatMotor)
     .token("your-slack-token")
     .channel("your-channel-id")
     .logger(LoggerFactory.getLogger(YourClass.class))
     .build();
 

After building the instance, you can use the notifyDocumentAvailable and dispatchDocument methods to send messages and files to Slack.

See Also:
SlackNotificationChannel.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