forEach(groupMemberNumber -> messages.add(createMessageTwiml(groupMemberNumber, twilioNumber, finalMessage)) ); return messages; } [ this code with imports on GitHub ] We build the finalMessage and add a Message to the list for each member of the group. I created a small helper method called createMessageTwiml to turn the Twilio library build template code into a single line. I thought it was worth it since we're going to be building Message objects multiple times in this class. This method looks like this: Java Copy the code private Message createMessageTwiml(String to, String from, String body) { return new Message.Builder() .

to(to) .from(from) .body(new Body.Builder(body).build()) .build(); } [ this code with imports on GitHub ] Messages from group members When a group member sends a message to the Twilio number, they must preface it with the actual destination number: A text message saying “+336xxxxx Thanks!” The "Thank you!" part of the message will be sent from the Twilio number to the number at the beginning of the message. Everyone in the group will also get a copy. To do this, the method messagesSentFromGroup needs to split the body of the message, check if it starts with a phone number (if not, send a reminder), and create a list of outgoing messages, like this: Java Copy the code private List<Message> messagesSentFromGroup(String fromNumber, String twilioNumber, String messageBody) { List<Message> messages = new ArrayList<>(); String[] messageParts = messageBody.