Configure an SMS service ready for sending messages. Supports templating with resource bundles.
Edit pom.xml, add the starter:
<dependency>
<groupId>io.57blocks</groupId>
<artifactId>sms-spring-boot-starter</artifactId>
<version>${io.57blocks.sms.version}</version>
</dependency>If twilio is selected as the backend for sending SMS:
<dependency>
<groupId>io.57blocks</groupId>
<artifactId>twilio-spring-boot-starter</artifactId>
<version>${twilio-spring-boot-starter.version}</version>
</dependency>Edit application.yml, add the following properties:
io.57blocks.sms:
enabled: true
message_base_name: /sms/messagesEdit application.yml for twilio credentials:
io.57blocks.twilio:
account_sid: ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
auth_token: your_auth_tokenDefault layout in /src/main/resources:
sms/
messages.properties
messages_zh.properties
To send messages, inject SmsService into the bean.
public class GreetingService {
@Autowired
private SmsService smsService;
public void sendMessage() {
smsService.send("+9876543210", "+1234567890", "greeting", Locale.ENGLISH,
new Object[]{"Mr. Smith"});
}
}