code: public final void handleTextMessage(WebSocketSession session, TextMessage textMessage) {
          ObjectMapper mapper = new ObjectMapper();
          logger.debug("Response from Slack: {}", textMessage.getPayload());
          try {
              Event event = mapper.readValue(textMessage.getPayload(), Event.class);
              if (event.getType() != null) {
                  if (event.getType().equalsIgnoreCase(EventType.IM_OPEN.name())
                          || event.getType().equalsIgnoreCase(EventType.IM_CREATED.name())) {
                      if (event.getChannelId() != null) {
                          slackService.addImChannelId(event.getChannelId());
                      } else if (event.getChannel() != null) {
                          slackService.addImChannelId(event.getChannel().getId());
                      }
                  } else if (event.getType().equalsIgnoreCase(EventType.MESSAGE.name())) {
                      if (event.getText() != null && event.getText().contains(slackService.getCurrentUser().getId())) { // direct mention
                          event.setType(EventType.DIRECT_MENTION.name());
                      } else if (slackService.getImChannelIds().contains(event.getChannelId())) { // direct message
                          event.setType(EventType.DIRECT_MESSAGE.name());
                      }
                  } else if (event.getType().equalsIgnoreCase(EventType.HELLO.name())) {
                      pingAtRegularIntervals(session);
                  }
              } else { // slack does not send any TYPE for acknowledgement messages
                  event.setType(EventType.ACK.name());
              }
  
              if (isConversationOn(event)) {
                  invokeChainedMethod(session, event);
              } else {
                  invokeMethods(session, event);
              }
          } catch (Exception e) {
              logger.error("Error handling response from Slack: {} \nException: ", textMessage.getPayload(), e);
          }
      }
docs: Invoked when a new Slack event(WebSocket text message) arrives.
  
  @param session     websocket session between bot and slack
  @param textMessage websocket message received from slack