sendMessage method

Future<void> sendMessage(
  1. ChatwootNewMessageRequest request
)
override

Sends message to chatwoot inbox

Implementation

Future<void> sendMessage(ChatwootNewMessageRequest request) async {
  try {
    final createdMessage = await clientService.createMessage(request);
    await localStorage.messagesDao.saveMessage(createdMessage);
    callbacks.onMessageSent?.call(createdMessage, request.echoId);
    if (clientService.connection != null && !_isListeningForEvents) {
      listenForEvents();
    }
  } on ChatwootClientException catch (e) {
    callbacks.onError?.call(
        ChatwootClientException(e.cause, e.type, data: request.echoId));
  }
}