Package com.chatmotorapi.api.notify
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SlackNotificationChannel.Builder
Builder class forSlackNotificationChannel
. -
Method Summary
Modifier and Type Method Description MotorNotifyResponse
dispatchDocument(String filePath, ExecutionMode mode)
Sends the generated response document to the user.MotorNotifyResponse
notifyDocumentAvailable(String filePath, ExecutionMode mode)
Notifies the user that a response document is available.
-
Method Details
-
notifyDocumentAvailable
Description copied from interface:NotificationChannel
Notifies the user that a response document is available.- Specified by:
notifyDocumentAvailable
in interfaceNotificationChannel
- Parameters:
filePath
- the file path of the response document that is availablemode
- the execution mode, either synchronous (SYNC) or asynchronous (ASYNC)- Returns:
- a MotorNotifyResponse object containing the result of the notification process
-
dispatchDocument
Description copied from interface:NotificationChannel
Sends the generated response document to the user.- Specified by:
dispatchDocument
in interfaceNotificationChannel
- Parameters:
filePath
- the file path of the response document to be sentmode
- the execution mode, either synchronous (SYNC) or asynchronous (ASYNC)- Returns:
- a MotorNotifyResponse object containing the result of the document dispatch process
-