code: public static Map<String, Object> updateUserTone(Map<String, Object> context, ToneAnalysis toneAnalyzerPayload,
        boolean maintainHistory) {
  
      List<ToneScore> emotionTone = new ArrayList<ToneScore>();
      List<ToneScore> languageTone = new ArrayList<ToneScore>();
      List<ToneScore> socialTone = new ArrayList<ToneScore>();
  
      // If the context doesn't already contain the user object, initialize it
      if (!context.containsKey("user")) {
        context.put("user", initUser());
      }
  
      // For convenience sake, define a variable for the user object to
      @SuppressWarnings("unchecked")
      Map<String, Object> user = (Map<String, Object>) context.get("user");
  
      if (toneAnalyzerPayload != null && toneAnalyzerPayload.getDocumentTone() != null) {
        List<ToneCategory> tones = toneAnalyzerPayload.getDocumentTone().getToneCategories();
        for (ToneCategory tone : tones) {
          if (tone.getCategoryId().equals(EMOTION_TONE_LABEL)) {
            emotionTone = tone.getTones();
          }
          if (tone.getCategoryId().equals(LANGUAGE_TONE_LABEL)) {
            languageTone = tone.getTones();
          }
          if (tone.getCategoryId().equals(SOCIAL_TONE_LABEL)) {
            socialTone = tone.getTones();
          }
        }
  
        updateEmotionTone(user, emotionTone, maintainHistory);
        updateLanguageTone(user, languageTone, maintainHistory);
        updateSocialTone(user, socialTone, maintainHistory);
  
      }
  
      context.put("user", user);
      return user;
    }
docs: updateUserTone processes the Tone Analyzer payload to pull out the emotion, language and social tones, and identify
  the meaningful tones (i.e., those tones that meet the specified thresholds). The assistantPayload json object is
  updated to include these tones.
  
  @param context the context
  @param toneAnalyzerPayload json object returned by the Watson Tone Analyzer Service
  @param maintainHistory the maintain history
  @return the map
  @returns assistantPayload where the user object has been updated with tone information from the
  toneAnalyzerPayload