Package com.chatmotorapi.api.notify
Class TwilioNotificationChannel
java.lang.Object
com.chatmotorapi.api.notify.TwilioNotificationChannel
- All Implemented Interfaces:
NotificationChannel
public class TwilioNotificationChannel extends Object implements NotificationChannel
The TwilioNotificationChannel
class handles sending SMS messages via Twilio as part of response post-treatment processes.
It provides methods to send SMS messages either synchronously or asynchronously, depending on the specified ExecutionMode
.
Usage
To create an instance of TwilioNotificationChannel
, use the nested TwilioNotificationChannel.Builder
class.
The following fields are required:
- accountSid: Your Twilio Account SID for authentication.
- authToken: Your Twilio Auth Token for authentication.
- fromPhoneNumber: The Twilio phone number from which messages will be sent.
- phoneNumbers: A list of recipient phone numbers.
- messageText: The SMS message content to be sent.
Optional field:
- logger: A custom
Logger
instance for logging operations. If not provided, a default logger will be used.
Example:
TwilioNotificationChannel twilioNotificationChannel = new TwilioNotificationChannel.Builder()
.chatMotor(chatmotor)
.accountSid("your-account-sid")
.authToken("your-auth-token")
.fromPhoneNumber("+1234567890")
.phoneNumbers(Arrays.asList("+0987654321", "+11234567890"))
.messageText("Your message here")
.logger(LoggerFactory.getLogger(YourClass.class))
.build();
After building the instance, you can use the notifyDocumentAvailable
method to send SMS messages.
Note that the dispatchDocument
method is not implemented and will throw an UnsupportedOperationException
if called.
- See Also:
TwilioNotificationChannel.Builder
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TwilioNotificationChannel.Builder
Builder class for TwilioNotificationChannel. -
Method Summary
Modifier and Type Method Description MotorNotifyResponse
dispatchDocument(String filePath, ExecutionMode mode)
Not implemented in this context.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
Not implemented in this context. Can not send file using SMS..- Specified by:
dispatchDocument
in interfaceNotificationChannel
- Parameters:
filePath
- the file path to send as responsemode
- the execution mode for sending the message (SYNC or ASYNC)- Returns:
- a MotorNotifyResponse object containing the result of the document dispatch process
-