import org.springframework.context.annotation.*;
import com.broadleafcommerce.notification.service.*;
import com.broadleafcommerce.notification.service.integration.TwilioMessageSender;
@Configuration
public class MyNotificationConfiguration {
// Step 1: Configure a TwilioMessageSender
@Bean
TwilioMessageSender twilioMessageSender() {
// Obtain an credentials and authorized sender mobile from Twilio
String accountSID = "TwilioAccountSID"; // This is usually the username
String authToken = "TwilioAuthToken";
String mobileNumber = "1-555-555-1234";
TwilioRestClient client = new TwilioRestClient.Builder(accountSID, authToken).build();
TwilioMessageSender = new TwilioMessageSender(client);
sender.setDefaultSenderMobile(mobileNumber);
return sender;
}
// Step 2: Register a SMS handler with the NotificationService
@Bean
NotificationHandler smsNotificationHandler(ThymeleafMessageBuilder builder,
TwilioMessageSender sender) {
return new DefaultNotificationHandler(builder, sender);
}
}