parsePhone function

String parsePhone(
  1. String phone
)

parsePhone will try to convert phone number in required format

Implementation

String parsePhone(String phone) {
  String chatSuffix = "@c.us";
  String phoneNum = phone.replaceAll("+", "");
  // Already has a valid WA suffix — leave as-is
  if (phoneNum.contains("@")) {
    return phoneNum;
  }
  return "$phoneNum$chatSuffix";
}