sendTextMessage method

Future sendTextMessage({
  1. required String phone,
  2. required String message,
  3. String? templateTitle,
  4. String? templateFooter,
  5. bool useTemplate = false,
  6. List<MessageButtons>? buttons,
  7. MessageId? replyMessageId,
})

sendMessage may throw errors if passed an invalid contact or if this method completed without any issue , then probably message sent successfully add replyMessageId to quote message

Implementation

Future sendTextMessage({
  required String phone,
  required String message,
  String? templateTitle,
  String? templateFooter,
  bool useTemplate = false,
  List<MessageButtons>? buttons,
  MessageId? replyMessageId,
}) async {
  String? replyText = replyMessageId?.serialized;
  String? buttonsText = buttons?.map((e) => e.toJson()).toList().toString();
  return await wpClient.evaluateJs(
      '''WPP.chat.sendTextMessage(${phone.phoneParse}, ${message.jsParse}, {
          quotedMsg: ${replyText.jsParse},
          useTemplateButtons: ${useTemplate.jsParse},
          buttons:$buttonsText,
          title: ${templateTitle.jsParse},
          footer: ${templateFooter.jsParse}
        });''',
      methodName: "sendTextMessage");
}