|
12 | 12 | @Service |
13 | 13 | @RequiredArgsConstructor |
14 | 14 | @EnableConfigurationProperties(TwilioConfigurationProperties.class) |
15 | | -public class ArticlePublishedNotificationDispatcher { |
| 15 | +public class WhatsappMessageDispatcher { |
16 | 16 |
|
17 | 17 | private final TwilioConfigurationProperties twilioConfigurationProperties; |
18 | 18 |
|
19 | | - public void dispatch(String phoneNumber, String articleUrl) { |
| 19 | + public void dispatchNewArticleNotification(String phoneNumber, String articleUrl) { |
20 | 20 | String messagingSid = twilioConfigurationProperties.getMessagingSid(); |
21 | 21 | String contentSid = twilioConfigurationProperties.getNewArticleNotification().getContentSid(); |
22 | 22 | PhoneNumber toPhoneNumber = new PhoneNumber(String.format("whatsapp:%s", phoneNumber)); |
23 | 23 |
|
24 | 24 | JSONObject contentVariables = new JSONObject(); |
25 | 25 | contentVariables.put("ArticleURL", articleUrl); |
26 | | - |
| 26 | + |
27 | 27 | Message.creator(toPhoneNumber, messagingSid, "") |
28 | 28 | .setContentSid(contentSid) |
29 | | - .setContentVariables(contentVariables.toString()) |
30 | | - .create(); |
| 29 | + .setContentVariables(contentVariables.toString()).create(); |
| 30 | + } |
| 31 | + |
| 32 | + public void dispatchReplyMessage(String phoneNumber, String username) { |
| 33 | + String messagingSid = twilioConfigurationProperties.getMessagingSid(); |
| 34 | + PhoneNumber toPhoneNumber = new PhoneNumber(String.format("whatsapp:%s", phoneNumber)); |
| 35 | + |
| 36 | + String message = String.format("Hey %s, our team will get back to you shortly.", username); |
| 37 | + Message.creator(toPhoneNumber, messagingSid, message); |
31 | 38 | } |
32 | 39 |
|
33 | 40 | } |
0 commit comments